Aly
03/22/2025, 4:50 PMCeligo AI
03/22/2025, 4:50 PMAI generated answer (using internal Slack threads):Based on the conversations, it seems that you are trying to change the value of a field on a form in a User Event script's beforeLoad function. However, it's important to note that the beforeLoad function is not the right place to make changes to the record's data. This function is mainly used to modify the form, not the record's data. If you want to change the value of a field on a record, you should use the beforeSubmit function. Here's a sample code snippet:
javascript
/**
* @NApiVersion 2.x
* @NScriptType UserEventScript
* @NModuleScope SameAccount
*/
define(['N/record', 'N/ui/serverWidget'], function(record, serverWidget) {
function beforeSubmit(context) {
if (context.type === context.UserEventType.CREATE || context.type === context.UserEventType.EDIT) {
var vendor = context.newRecord;
var formId = vendor.getValue({ fieldId: "customform" }); // replace with your form id field
if (formId == 216) {
vendor.setValue({ fieldId: "isperson", value: false });
}
}
}
return {
beforeSubmit: beforeSubmit
};
});
This script will set the 'isperson' field to false when the form ID is 216. Please replace "customform" with your actual form id field.
******
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
03/22/2025, 4:50 PMSlack thread 1: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.81884
Slack thread 2: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.806077719
Slack thread 3: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.805557251
Celigo AI
03/22/2025, 4:50 PM