In NetSuite, a user event script was deployed on a transaction record to change its status based on certain conditions during the save process, using the AfterSubmit entry point with record.submitFields. Another user event script was deployed to compare the old and new status values. If the status changed to “Cancelled,” further actions were required. However, the status change trigger did not work reliably in the second script. To fix this, we used a Suitelet script with a POST action to set the status. This approach allowed us to capture both the old and new status values accurately, and the second user event script will perform the necessary actions based on the status change. This solution improved the reliability of the status change detection and subsequent processing.
In User Event Script,
let suiteletUrl = url.resolveScript({
scriptId: "customscript_sl_donat_email_jstn1753",
deploymentId: "customdeploy_sl_donat_email_jstn1753",
returnExternalUrl: true
})
let headerObj = { name: 'Accept-Language', value: 'en-us' };
let requesturl = suiteletUrl + '&apitype=set_status&custbody_jcs_linkedif=' + newRecord.id + '&transtatus=' + TRAN_STATUS.converted + '&pendingdonation=' + pendDonId + '¤tuser=' + currentUserId;
let response = https.post({ url: requesturl, body: {}, headers: headerObj });
In Suitelet script,
if (context.request.method == 'POST') {
record.submitFields({
type: 'customsale_jcs_pendingdonation',
id: pendingDonationRecordId,
values: {
custbody_jcs_linkedif: linkedIF,
transtatus: status,
custbody_jcs_current_user: currentUser
}
});
}