clientscript postsourcing vs fieldchanged
# ask-stanley-ai
b
clientscript postsourcing vs fieldchanged
c
AI generated answer (using internal Slack threads):
In NetSuite, both
fieldChanged
and
postSourcing
are client script trigger types, but they are used in different scenarios and have different behaviors. The
fieldChanged
trigger is fired when a field is changed on the client side. This could be due to user interaction or a script changing the field value. It's important to note that
fieldChanged
is triggered after the field value has been changed and all sourcing has been completed. This trigger type is useful when you want to perform an action immediately after a field value has been changed. On the other hand, the
postSourcing
trigger is fired after a field is sourced from another record. This is typically used when you want to perform an action after a field has been populated from a source record. It's important to note that
postSourcing
is triggered after the field value has been sourced and all sourcing has been completed. In terms of performance, there is no definitive answer as it depends on the specific use case and the complexity of the script. However, it's worth noting that
fieldChanged
might be more efficient in some cases as it is triggered immediately after a field value has been changed, whereas
postSourcing
is triggered after all sourcing has been completed. Here is an example of how you might use these triggers in a client script:
Copy code
javascript
function fieldChanged(context) {
    if (context.fieldId === 'custbody_my_custom_field') {
        // Perform some action
    }
}

function postSourcing(context) {
    if (context.fieldId === 'custbody_my_sourced_field') {
        // Perform some action
    }
}
Remember, the choice between
fieldChanged
and
postSourcing
will depend on your specific use case and the behavior you want to achieve. ****** 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.827510536
Slack thread 2: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.826198339
Slack thread 3: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.82316
Please provide your feedback on this answer.