Adam Weaver
11/19/2024, 1:02 PMCeligo AI
11/19/2024, 1:02 PMAI generated answer (using internal Slack threads):The script you provided is a User Event script that is designed to generate a GL Impact PDF and send it via email after a record is submitted. However, there is a mistake in the script. The
render.glImpact
function does not exist in SuiteScript 2.x.
Instead, you should use the N/render
module's transaction
function to generate a PDF of the GL Impact. Here's how you can modify your script:
javascript
/**
*@NApiVersion 2.x
*@NScriptType UserEventScript
*/
define(['N/render', 'N/email'],
function(render, email) {
function afterSubmit(context) {
try {
log.debug('Context', JSON.stringify(context));
// Get the record ID from the workflow context
let recordId = context.currentRecord.id;
// Generate the GL Impact PDF
let pdfFile = render.transaction({
entityId: recordId,
printMode: render.PrintMode.PDF,
inCustLocale: true
});
// Send the email
email.send({
author: -5, // System user
recipients: ['<mailto:aweaver@ruscoe.com|aweaver@ruscoe.com>'],
subject: 'GL Impact Sheet for Record ' + recordId,
body: 'Please review the attached GL Impact Sheet.',
attachments: [pdfFile]
});
} catch (e) {
log.error('Error sending GL Impact Sheet', e.message);
}
}
return {
afterSubmit: afterSubmit
};
}
);
This script will generate a PDF of the transaction (which includes the GL Impact) and send it via email.
******
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
11/19/2024, 1:02 PMSlack thread 1: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.89235425
Slack thread 2: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.885957
Slack thread 3: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.874418914
Celigo AI
11/19/2024, 1:02 PM