In a user event (aftersubmit) attached to the sale...
# ask-stanley-ai
l
In a user event (aftersubmit) attached to the sales order record, is it possible to know (when transformed) what's the target record type?
c
AI generated answer (using internal Slack threads):
In a User Event script (afterSubmit) attached to the Sales Order record, it is not directly possible to know the target record type when the Sales Order is transformed. The afterSubmit event does not provide any context about the transformation target. However, you can potentially work around this by using a SuiteScript to create a custom field on the Sales Order record to store the target record type during the transformation process. This custom field can then be accessed in the afterSubmit event to determine the target record type. Here is a sample code snippet that demonstrates this approach:
Copy code
javascript
function beforeSubmit(context) {
    if (context.type === context.UserEventType.CREATE) {
        var newRecord = context.newRecord;
        var transformedRecordType = newRecord.getValue('custbody_transformed_record_type');
        if (transformedRecordType) {
            // The Sales Order was transformed from another record type
            // Perform your logic here
        }
    }
}
In this example, 'custbody_transformed_record_type' is a custom field that you would create on the Sales Order record to store the target record type during the transformation process. Please note that this approach requires you to have control over the process that transforms the Sales Order, as you would need to set the 'custbody_transformed_record_type' field during that process. ****** 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.843250692
Slack thread 2: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.839473486
Slack thread 3: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.839355111
Please provide your feedback on this answer.