Test Before You Script

One of my favorite Netsuite tricks is that suitescript APIs can be used in the dev console.  Especially for beginning developers, finding the right API, internal id, etc.. can be tricky but by using the dev console you can get a real time example of how your script will affect a record. 

Here’s an example: 

Your client has has an integration with a 3PL that generates Item Fulfillment records when the 3PL picks the order.  The problem is that the 3PL’s shipping cost and what the client charge for shipping don’t match.  The client requests that the shipping cost from the sales order be used on the invoice instead of the item fulfillments shipping cost.  We’ll use the dev console to work through the code and see what works, and if we make a mistake we can just refresh the page to try again. 

On an invoice first we’ll need the sales order record, 

var createdFrom = nlapiGetFieldValue(‘createdfrom’); 

Variables you create in the dev console will stick around until you navigate away or refresh the page. 

var salesOrder = nlapiLoadRecord(‘salesorder’, createdFrom); 

Now we can access all the sales order data, lets grab the shipping cost. 

var salesOrderShippingCost = salesOrder.getFieldValue(‘shippingcost’); 

Great!  Now to put it in it’s new home. 

nlapiSetFieldValue(‘shippingcost’, salesOrderShippingCost); 

We can now collect all our lines of code into a function and created a script record and deployment for the client’s use case.  The above example is simple but using the dev console during troubleshooting scripts can be immeasurably valuable in understanding how your code is interacting with Netsuite. 

Author: GDS Navigating the labyrinth of finance can feel like...

Read More

Author: GDS Navigating the field service and delivery landscape is...

Read More

The Comprehensive Advantages of Implementing an Absorption Costing Model The...

Read More

Schedule A Meeting Today!

Leave a Reply

Your email address will not be published. Required fields are marked *