Luis
09/10/2024, 8:37 PMCeligo AI
09/10/2024, 8:38 PMAI generated answer (using internal Slack threads):To change the data used in the PDF template preview, you can use the
beforeLoad
function in SuiteScript to add a custom field to the record. This custom field can then be picked up in the Advanced PDF template. Here's a simplified example:
javascript
function beforeLoad(context) {
if (context.type !== context.UserEventType.VIEW) return;
var newField = context.newRecord.addField({
id: 'custpage_my_custom_field',
label: 'My Custom Field',
type: serverWidget.FieldType.TEXT
});
newField.defaultValue = 'My Custom Value';
}
In the Advanced PDF template, you can then reference this custom field like this:
xml
<#if record.custpage_my_custom_field?has_content>
${record.custpage_my_custom_field}
</#if>
This method works for both UI and server-side scripting.
If you need to change the entire template based on a status or other condition, you can use the N/render.transaction
function with the formId
specified. Alternatively, you can create a custom form for each status and associate the PDF template to each of those forms. Then, use the appropriate form for the appropriate status to render the correct PDF without SuiteScript or workflow.
******
Disclaimer:
This response was generated by an artificial intelligence assistant based on previous conversations from multiple Slack channels, and may contain inaccuracies or mistakes.
******Celigo AI
09/10/2024, 8:38 PMSlack thread 1: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.812237382
Slack thread 2: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.811519444
Slack thread 3: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.80970186
Celigo AI
09/10/2024, 8:38 PM