James Morris
11/21/2024, 8:46 PMCeligo AI
11/21/2024, 8:46 PMAI generated answer (using internal Slack threads):Based on the conversations, it seems you want to create a SuiteScript 2.0 server script to update the external ID field of all vendor payment records upon their creation. Here's a basic example of how you might do this using a User Event Script:
javascript
/**
* @NApiVersion 2.x
* @NScriptType UserEventScript
* @NModuleScope SameAccount
*/
define(['N/record', 'N/runtime'], function(record, runtime) {
function afterSubmit(context) {
if (context.type !== context.UserEventType.CREATE)
return;
var newRecord = context.newRecord;
var externalIdValue = 'Your Value'; // Replace with your logic to generate external ID
try {
record.submitFields({
type: newRecord.type,
id: newRecord.id,
values: {
externalid: externalIdValue
},
options: {
enableSourcing: false,
ignoreMandatoryFields : true
}
});
} catch (e) {
log.error({
title: 'Error updating External ID for ' + newRecord.type + ' ' + newRecord.id,
details: e
});
}
}
return {
afterSubmit: afterSubmit
};
});
This script will run after a vendor payment record is created and will update the external ID field with the value you specify. Please replace 'Your Value'
with your logic to generate the external ID.
******
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/21/2024, 8:47 PMSlack thread 1: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.833563268
Slack thread 2: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.83264786
Slack thread 3: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.832031727
Celigo AI
11/21/2024, 8:47 PM