Has anyone managed to print a PDF of a custom reco...
# suitescript
j
Has anyone managed to print a PDF of a custom record and store in File Cabinet, via SuiteScript?
e
You can create your own Advanced PDF template and use the same syntax (I do not remember right now the name). You load your template and pass your custom source data to generate a PDF file. All of this with native SuiteScript modules.
n
Custom records usually have an adv pdf template generated on creation of the record definition which you can customise much like standard transaction records. You can use the n/render module to create a PDF and then store it. No need to use custom source data you use the fields as seen on the custom record "record.<field_id>". Images include custom record entry and pdf template associated with it. If you cannot access the template by id for some reason you may need to take the source and merge in your data in script.(I don't recall if I had to or not)
j
my record has 1000 fields…..
hoping to avoid having to create a template for obvious reasons
e
You can create a template, that is not the issue. Actually that is the solution but you do not need to pass the full data to your template. Take a look at this:
addCustomDataSource
on the N/render module. You might use something like this:
renderer.addCustomDataSource({
alias: 'testobject',
format: render.DataSource.OBJECT,
data: your_desired_custom_data_object
});
j
Hm. Not sure I get it. I basically want a way to make it print exactly as it does if you press the “print” button in the UI.
n
Not sure I follow, for custom records I've created you have a basic template and pressing print on a record instance prints a PDF. You can customise that template, you don't have to though. If you want a custom button someplace you can reference the template generated and use it "as is" with n/render, you just might need to confirm this aspect as you may have to download the XML and include it in your button script/in the file cabinet. Sorry I have to logoff (I'm in the UK so 7 hours ahead it seems), but feel free to DM me. (I also realise you posted this 5 days ago and may have moved on!)