how to access body field created by user event scr...
# ask-stanley-ai
d
how to access body field created by user event script in advance pdf
c
AI generated answer (using internal Slack threads):
Based on the conversations, to access a body field created by a User Event Script in an Advanced PDF, you can use the
beforeLoad
event type of the User Event Script to add a custom field to the form. This field will not be stored on the record but will be accessible in the Advanced PDF template. Here is a sample code snippet that demonstrates this:
Copy code
javascript
function beforeLoad(context) {
    if (context.type === context.UserEventType.PRINT) {
        let newField = context.form.addField({
            id: 'custpage_my_field',
            type: serverWidget.FieldType.TEXT,
            label: 'My Custom Field'
        });
        newField.defaultValue = 'My Custom Value';
    }
}
In the Advanced PDF template, you can then access this field using the following syntax:
Copy code
html
${record.custpage_my_field}
Please note that the field is added to the form, not the record itself. Therefore, the value won't be stored anywhere if you plan to use it in the context EDIT. ****** Disclaimer: This response was generated by an artificial intelligence assistant based on previous conversations from multiple Slack channels, and may contain inaccuracies or mistakes. ******
Slack thread 1: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.814072609
Slack thread 2: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.80204
Slack thread 3: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.799421906
Please provide your feedback on this answer.