Sunday, May 26, 2019

Change a sales order item tax code using client script

To change a sales order item tax code using client script on Line Item Level please refer to the sample script below deployed on a save Record function  :

function clientSaveRecord() {

    nlapiSelectLineItem('item', 1) // Select tax code on which line item needs to be changed
    nlapiSetCurrentLineItemValue('item', 'taxcode', 7, true, true); // Tax code internal id's can be found from Setup > Accounting > Tax Codes
    nlapiCommitLineItem('item');

    return true;

}


- One can even sort through all the line items present on the record and perform updates based on required conditions. In order to iterate through all line items present please refer to the sample script below :

function clientSaveRecord() {

    var count = nlapiGetLineItemCount();

    for (i = 1; i < count; i++)
        {

        nlapiSelectLineItem('item', i) // Select tax code on which line item needs to be changed
        nlapiSetCurrentLineItemValue('item', 'taxcode', 7, true, true);
        nlapiCommitLineItem('item');

        return true;

    }

}


Disclaimer: The above sample requires working knowledge in SuiteScript. Support to the sample code is not warranted.  The test cases conducted for the above sample is very limited and there is no guarantee that it will work in the future versions of NetSuite. Netsuite Inc. shall not be liable for any direct, indirect or consequential damages or costs of any type arising out of any action taken by you or others related to the sample code.

No comments:

Post a Comment