Hi Everyone. I am not able to set a Tax Code on th...
# suitescript
n
Hi Everyone. I am not able to set a Tax Code on the sales order line item. The same is the case with the Shipping tax code. Any help is appreciated.
b
you might want to be more specific
is there an error?
do you have code that tries to set the tax but it simply isn't working
does it work in the ui?
n
Yes, it works in the UI if the set that Tax Code via client script
But in the Map Reduce script, it does not set the Tax Code that I want.
The Internal ID is valid, I have verified it
b
what does the code look like
n
salesOrderRec.setSublistValue({ //Set Tax Code sublistId: 'item', fieldId: 'taxcode', line: i, value: parseInt(orderSettings.ORDER.TAX_CODE) }); salesOrderRec.setSublistText({ //Set custom tax rate sublistId: 'item', fieldId: 'taxrate1', line: i, value: (taxOnLine * 100) + '%' });
b
setSublistValue uses value for the value
setSublistText uses text for the value
salesOrderRec.setSublistText({ //Set custom tax rate sublistId: 'item', fieldId: 'taxrate1', line: i, text: (taxOnLine * 100) + '%' });
n
Oh, but this is not the issue right now.
This is the issue. salesOrderRec.setSublistValue({ sublistId: 'item', fieldId: 'taxcode', line: i, value: parseInt(orderSettings.ORDER.TAX_CODE) });
This tax code has the Rate for 1.0%
But this Tax Code is not being set on the Line Items
b
your taxcode setting looks reasonable
i say try hardcoding the tax code
n
Yeah, I have tried both Standard and Dynamic mode
OK, let me try that
b
make sure there are no other scripts or workflows trying to set taxcode
n
Hardcoding tax code didn't work
Could it be Tax Schedule issue? Item is Not Taxable on the Tax Schedule. But I can set it via UI
Should I try to set the TaxTotal via script?
b
you cant set taxTotal
its calculated by netsuite
tax schedule should only choose the default taxcode, which you override
i say disable all user events and workflows and try again
n
Okay.
Didn't work
Disabled all UE and WFs. Didn't help
Any other suggestion?
b
use suitescript debugger
use something simple to try and create your sales order
n
I can use the created sales order
b
Copy code
require(["N/record"], function(record) {
  var salesOrderRec = record.create({ type: "salesorder", isDynamic: false });
  salesOrderRec.setValue({ fieldId: "entity", value: "aValidId" });
  salesOrderRec.setSublistValue({
    sublistId: "item",
    fieldId: "item",
    value: "aValidItemInternalId",
    line: 0
  });
  salesOrderRec.setSublistValue({
    sublistId: "item",
    fieldId: "taxcode",
    line: 0,
    value: 'yourTaxCode'
  });
  salesOrderRec.setSublistText({
    sublistId: "item",
    fieldId: "taxrate1",
    line: 0,
    text: 'somePercentage%'
  });
  salesOrderRec.save();
});
n
It got set
I updated the sales order
via debugger.. and it worked
b
you can try the fragment in your script
n
One more thing..
I was not able to set tax code for shipping. I saved the SO, loaded it, and set the Shipping Tax Code. It was set.
Copied the fragment from my debugger code.
That worked!
Atleast the taxcode was set
b
you might need to explain the shipping tax code better
n
There is Tax Code for Shipping Cost as well.
b
your comment says you loaded it, set the shipping tax code and it was set
n
Yes.
Everything is working now.
I saved the SO, loaded it again. Set both tax code and rate. and saved it again.
All good now.
But one thing is that the I used the chunks from the Debugger script.
My original code to get the code from the "settings" is not working
b
good luck on that code
n
is there a problem?
b
i wouldnt know
n
Ok.. but Thank you for help.