How to modify Related Records view on Sales Orders
# ask-stanley-ai
m
How to modify Related Records view on Sales Orders
c
AI generated answer (using internal Slack threads):
To modify the Related Records view on Sales Orders, you would need to create a User Event script on the Sales Order's after submit entry point. This script would look for an estimate in the created from field and then use the
record.submitFields
method to set the Sales Order's ID to a custom field on the quote body. Here is a basic example of how you might structure this script:
Copy code
javascript
/**
 * @NApiVersion 2.x
 * @NScriptType UserEventScript
 */
define(['N/record'], function(record) {
    function afterSubmit(context) {
        if (context.type !== context.UserEventType.CREATE) {
            return;
        }
        var salesOrder = context.newRecord;
        var createdFrom = salesOrder.getValue('createdfrom');
        if (createdFrom) {
            record.submitFields({
                type: record.Type.ESTIMATE,
                id: createdFrom,
                values: {
                    'custbody_related_sales_order': salesOrder.id
                }
            });
        }
    }
    return {
        afterSubmit: afterSubmit
    };
});
In this script,
custbody_related_sales_order
is a custom field on the quote body that will hold the ID of the related Sales Order. Please note that this script does not account for the quote being converted to multiple sales orders (the most recent one would override the field). You may also need to account for quotes being converted directly into invoices (and cash sales) if your business process allows for that. ****** 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.832214475
Slack thread 2: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.83215344
Slack thread 3: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.827392697
Please provide your feedback on this answer.