upon creating a sales order via suitescript, NetSu...
# ask-stanley-ai
d
upon creating a sales order via suitescript, NetSuite is populating the preferred shipping method from the customer, how can I clear it out and set another shipping method?
c
AI generated answer (using internal Slack threads):
To clear out the preferred shipping method from the customer and set another shipping method when creating a sales order via SuiteScript, you can use the
setValue
method on the sales order record. Here is a sample code snippet:
Copy code
javascript
var salesOrder = record.create({
    type: record.Type.SALES_ORDER,
    isDynamic: true,
});

// Set the customer
salesOrder.setValue({
    fieldId: 'entity',
    value: customerId
});

// Clear out the preferred shipping method and set a new one
salesOrder.setValue({
    fieldId: 'shipmethod',
    value: newShippingMethodId
});

var salesOrderId = salesOrder.save({
    enableSourcing: true,
    ignoreMandatoryFields: true
});
In this code snippet,
customerId
is the internal ID of the customer and
newShippingMethodId
is the internal ID of the new shipping method you want to set. Please note that you need to ensure that the new shipping method is valid for the customer's subsidiary and location. If the shipping method is not valid, NetSuite will throw an 'Invalid field value' error. ****** 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.849584639
Slack thread 2: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.839277804
Slack thread 3: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.834193349
Please provide your feedback on this answer.