Probably already discussed, but I really need ask ...
# advancedpdf
z
Probably already discussed, but I really need ask again > Customer has customized Invoice Advanced PDF Template. There is one additional set of data, doesn't matter saved search or sublist (child records). They want to continue with using standard actions (print, email) for invoice. I have some solutions with custom script (button on the form, suitelet with rendering and adding datasources to renderer) but it is very hard to administrate this. And questions are • is there any solutions to add additional list to record object (record object in Advanced PDF Template). What if we create custom record, make Invoice as parent, is there option to reference that sublist something like <#list record.rechmachparent_field as mylist> • I tried, but without success, create Before Load event for invoice, and add there some object : newRecord.myobject = [{....}, {....}] and after that tried to reference in PDF Template record.myobject ... as excpeted no success • I tried to create Inline HTML field šŸ™‚ and again inside Before Load event, put some HTML content (just for testing), put record.myInlineHTML field in PDF Template, and as expected unfortunately, NetSuite print content as string Any idea for this ... Once again, do not suggest scripting from the scratch, we already use that for other customer requests, and we are familiar with that. We are asking for injecting data or adding custom sublist to "standard" PDF Template functionality
s
you should be able to add a field on before load and set value through user event script. that field including the value then becomes available on the PDF template. make sure you filter the execution context to user event so it will not run unnecessarily on record view, edit, etc.
z
That's work... but only value from that field can be printed... Trick I was tried is InlineHTML field, and expected to "inject" html content in result of rendering. But, NetSuite do escaping string, and I got literally string value
s
I had a similar scenario. below code in the PDF template should do the trick:
<#assign fieldData = record.custrecord_field_id?replace("<", "<")?replace(">", ">")>
${fieldData}
I had my html content in a text area though, not inline html field
z
@Selcuk Dogru Wow it works
fyi, InlineHtml works also
Copy code
const beforeLoad = (scriptContext) => {
                newRecord = scriptContext.newRecord;
                newRecord.myobject = '[{"kljuc" : "Vredmost"},{"kljuc2" : "vrednost2"}]';
                newRecord.setValue({
                        fieldId : 'custbody_rdata_inline_html',
                        value : '<p>Text</p>'
                })
my favorite solution will be how to send JSON as string and then parse it inside Template
I found this example
Copy code
<#assign beer_json_string = '{ "name": "Imperial Stout", "description": "Tasty Stout Beer"}'>
    ${beer_json}
  
<#assign beer_map = beer_json_string?eval>
<p>
  ${beer_map.name}
  </p>
and it works, I got beer name as output, NetSuite print "Imperial Stout" But PDF designer DOES NOT accept if I replace fixed string with invoice custom field ... Some strange errors šŸ™‚
s
šŸ˜€ you got yourself another challenge
w
You can add a custpage_yourfield in before load as a long text. Insert a stringified object in it and then ?eval it. Note that it can beach sensitive to null values.