My default isperson on vendor records is TRUE but ...
# ask-stanley-ai
a
My default isperson on vendor records is TRUE but I want to set it as FALSE when the form ID is 216. How do I achieve this? beforeLoad UE does not work
c
AI 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:
Copy code
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. ******
Slack 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
Please provide your feedback on this answer.