Hello experts, I need your light regarding a tech...
# suitescript
d
Hello experts, I need your light regarding a technical subject that is still escaping my comprehension. The subject is: UserEventScript with PRINT as eventType. I noticed that the script is triggered on beforeLoad with PRINT event when I click on the standard button print on my transaction form. However, I don't understand how I can use this to my advantage since neither changes on context.NewRecord is reflected on printout nor any global variable created can be called/used on advancedPdfHtml. So what is the use of triggering a userEventScript on print event ?
n
I've never relied on this but you can add a custom field to a record in beforeload that is not stored on the record but would be accessible in an advanced print template. It's entirely possible in my mind that's what you'd use this for as you may never want to see the field in any other scenario. @Damree Ilyaad
d
I didnt test this scenario. What I did was to overwrite the memo field and displaying the new value. However the actual result was that I still got the initial value of the memo.
n
You cannot overwrite field value son beforeLoad
You could create a custpage_my_memo field and populate that and reference it in your print though.
^^ create it in the beforeload
d
I will test it today and revert back to you.
z
BeforeLoad UserEvent only for PRINT
Copy code
....

 let jsonData = {
                new_layout : 0,
                hasJob: false,
                hasTask: false,
                hasEmpl: false........
                jsonArray: jsonArray,            


newRecord.setValue({
                fieldId: 'custbody_rdata_inline_html',
                value: JSON.stringify(jsonData)
            });
and later in AdvancedPDF Template
Copy code
<#assign my_json = record.custbody_rdata_inline_html?eval>