Hi, I have created some custom transaction pdf for...
# suitescript
m
Hi, I have created some custom transaction pdf forms using xml and the freemarker/bfo tools available in advanced pdf. I am rendering the form through a suitelet using the N/render module and I’m adding a few different records using TemplateRenderer.addRecord(). For the time being, I have created a button to the transaction record pages, which opens the printable pdf in a new tab. However, I would like to link the template to the default print button, as you can do with an advanced pdf form. Is this at all possible, either out of the box or by some sort of workaround? (I will be posting this to both #C466X49JB and #C29HQS63G, as I don’t know which of the two is the most appropriate for my question.)
a
There is no way to override the native Print button click, you will need some DOM manipulation(not recommended), but instead you can write a UserEvent script and build the objects/data into custom hidden fields in the record, then with the native Advanced PDF Template that would be loaded upon clicking the Print button you can build logic to leverage those custom fields where you stored the additional data you need.
m
That would probably be the best solution then, thank you. I haven’t worked too much with advanced pdf or freemarker before, so may I ask if I need one field per piece of information I want to store, or can I store it as objects and access the specific key/value pairs in the pdf template? I know there are hashes in freemarker so maybe I can create a hash and assign the field value (stored as a stringified json object) as its value?