How can I default the Location on Web Store orders...
# ask-stanley-ai
a
How can I default the Location on Web Store orders to a different Location than the default location for Sales Orders in general (Accounting Preferences > Order Management)? This preference seems to control both, even so much that a User Event Script confirmed to run when the web store shopper user places their order, it forces the value to a different location, but the error still occurs saying "Transaction subsidiary AlcSource is not valid for location BevSource. Please choose a different location", which means that the Accounting preference somehow overrode value set by the script, after it set it. How do I make the web store-generated sales orders' location default to another location than the default for sales orders not generated by the web store? I have to do this or the order cannot be placed due to the default location on the order being outside the web store's subsidiary.
c
AI generated answer (using internal Slack threads):
Based on the conversations, it seems that the location for a Sales Order in NetSuite is typically set by the location of the Employee's record or the location defined on the Customer record. However, for web store orders, you are encountering an issue where the Accounting Preferences are overriding the location set by a User Event Script. To resolve this, you could consider the following approach: 1. Create a custom field on the Customer record that will hold the location for web store orders. This field should be a list/record field with the source list being the list of locations. 2. Create a Workflow or a User Event Script that triggers on the creation of a Sales Order. This Workflow/Script should check if the order is being created from the web store. If it is, it should set the location on the Sales Order to the value in the custom field on the Customer record. Here is a pseudo-code example of how the User Event Script might look:
Copy code
javascript
function beforeSubmit(context) {
    if (context.type !== context.UserEventType.CREATE)
        return;

    var newRecord = context.newRecord;
    var isWebStore = newRecord.getValue('custbody_web_store_order');

    if (isWebStore) {
        var customerId = newRecord.getValue('entity');
        var customerRecord = record.load({
            type: record.Type.CUSTOMER,
            id: customerId
        });

        var webStoreLocation = customerRecord.getValue('custbody_web_store_location');
        newRecord.setValue('location', webStoreLocation);
    }
}
In this script, 'custbody_web_store_order' is a custom field on the Sales Order that indicates if the order is from the web store, and 'custbody_web_store_location' is the custom field on the Customer record that holds the location for web store orders. ****** 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.871822178
Slack thread 2: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.863520145
Slack thread 3: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.849913061
Please provide your feedback on this answer.
Thank you for your feedback