Reputation: 13536
I have created a SuiteScript UserEventScript, which is called by an Advanced PDF/HTML Template, which gets triggered when printing to PDF from an invoice, but doesn't seem to get triggered when sending an email through Invoice > Actions > Email (which includes that same PDF template).
The reason I think the UserEventScript doesn't get triggered when emailing is that script's execution log doesn't contain any logging when emailing, but does contain logging when printing to PDF.
The top of the script:
Printing invoice to PDF:
Emailing
Upvotes: 0
Views: 102
Reputation: 13536
I ended up changing my SuiteScript UserEventScript to write the data to a field added to the Invoice, rather than adding a field during the UserEventScript. That way the template could always see this field since it was always present, even if the UserEventScript wasn't running during the email context.
Upvotes: 0
Reputation: 15447
When you print a transaction as a PDF or when you email a transaction using an Advanced Template the Before Load user script is called with type Print
.
This is controlled by the customer's email preference field or by the system level email preference field.
When the preference field is 'Email' then the email body will be formatted using the Advanced Template. The print event will be called so you can populate any custom fields or lists needed by the template
When the preference field is 'PDF' then the email body will be generated from the transaction's form's Email Message Template. As far as I can tell no user event is called for that operation. The attachment though is generated using the Advanced Template and all before Load user events are called with a print event.
Upvotes: 1