ANS-1538 · WEB SERVICES & INTEGRATIONS
How to Manage Shipping Cost Recalculation in NetSuite Web Services?
Understand the differences in shipping cost calculation between NetSuite UI and web services, and how to prevent unintended recalculations.
Short answer
NetSuite web services automatically recalculate altshippingcost when item quantities or other relevant fields are updated, unlike the UI. To maintain a specific shipping cost, the altshippingcost value must be explicitly resubmitted with each update. This ensures the system retains the desired shipping amount, preventing automatic adjustments.
Scenario
The calculation of shipping costs for sales orders in NetSuite web services differs from the behavior observed in the user interface. In the UI, the presence of a 'Calculate Shipping' button means that changes to item quantities or other values affecting shipping do not automatically trigger a recalculation of the shipping cost. However, when using NetSuite web services, any updates to item quantity or other fields that influence shipping costs will always result in the automatic recalculation of the altshippingcost field.
Solution
To prevent the automatic recalculation of altshippingcost when updating item quantities or other relevant fields via NetSuite web services, the existing altshippingcost value must be explicitly resubmitted with the transaction. If the NetSuite account is configured to automatically charge for shipping, the altshippingcost will default to the value corresponding to the selected shipping method upon recalculation.
The following SuiteScript 1.0 example demonstrates how to explicitly set the shippingcost field to its current value to prevent recalculation. While this snippet uses legacy SuiteScript 1.0 functions, the underlying principle of explicitly setting the shipping cost remains relevant. For new development, it is recommended to use SuiteScript 2.x equivalent methods.
nlapiCommitLineItem('item');
// to prevent the recalc of shipping cost from the webservices
var shippingcost nlapiGetFieldValue('shippingcost');
nlapiSetFieldValue('shippingcost',shippingcost);Expert NetSuite Support
Need help with this NetSuite issue?
Web Services & Integrations consulting and configuration support
