when a return authorization changes status from "P...
# ask-stanley-ai
m
when a return authorization changes status from "Pending Receipt" to "Pending Refund" how do I see that event in a user event suite script?
c
AI generated answer (using internal Slack threads):
To see the event of a return authorization changing status from "Pending Receipt" to "Pending Refund" in a user event SuiteScript, you would need to use the
beforeSubmit
or
afterSubmit
events in your user event script. In these events, you can check the old and new status of the record. If the old status was "Pending Receipt" and the new status is "Pending Refund", then you know that the status has changed in the way you're interested in. Here is a sample code snippet:
Copy code
javascript
function afterSubmit(context) {
    if (context.type !== context.UserEventType.CREATE && context.type !== context.UserEventType.EDIT) {
        return;
    }

    var newRecord = context.newRecord;
    var oldRecord = context.oldRecord;

    var newStatus = newRecord.getValue('status');
    var oldStatus = oldRecord.getValue('status');

    if (oldStatus === 'Pending Receipt' && newStatus === 'Pending Refund') {
        // The status has changed from 'Pending Receipt' to 'Pending Refund'
        // Add your code here
    }
}
Please note that the field id for status might be different in your account, so you might need to adjust the field id in the
getValue
function. ****** 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.814672112
Slack thread 2: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.814056695
Slack thread 3: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.809717417
Please provide your feedback on this answer.
i
Hi mike