Adam Weaver
11/19/2024, 2:49 PMCeligo AI
11/19/2024, 2:49 PMAI generated answer (using internal Slack threads):The script you provided is a Workflow Action Script in SuiteScript 2.0. It generates a PDF of the GL Impact of a transaction, saves it in the File Cabinet, and attaches it to the transaction record. Here is the corrected version of the script:
javascript
/**
* @NApiVersion 2.x
* @NScriptType WorkflowActionScript
*/
define(['N/render', 'N/file', 'N/record'], function (render, file, record) {
function onAction(context) {
try {
// Get the current transaction ID
var assemblyId = context.newRecord.id;
// Generate the GL Impact PDF
var pdfFile = render.transaction({
entityId: assemblyId,
printMode: render.PrintMode.PDF
});
// Save the file in the File Cabinet
var savedFile = file.create({
name: 'GL_Impact_' + assemblyId + '.pdf',
fileType: file.Type.PDF,
contents: pdfFile.getContents(),
folder: 12345 // Replace with your File Cabinet folder ID
});
var fileId = savedFile.save();
// Attach the file to the transaction record
record.attach({
record: {
type: record.Type.FILE,
id: fileId
},
to: {
type: record.Type.TRANSACTION,
id: assemblyId
}
});
log.audit('Success', 'GL Impact PDF generated and attached successfully.');
} catch (error) {
log.error('Error Generating GL Impact PDF', error.message);
throw error; // Re-throw the error to inform the workflow of the failure
}
}
return {
onAction: onAction
};
});
******
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, 2:49 PMSlack thread 1: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.847320318
Slack thread 2: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.845299244
Slack thread 3: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.842111349
Celigo AI
11/19/2024, 2:49 PMCeligo AI
11/19/2024, 8:15 PM