Dear NS community,
I am trying to access and update (via suitescript) particular Tax Schedule records (Setup→Accounting→Tax Schedules), and also the "Set up Taxes" page (Setup→Accounting→Set up Taxes).
For the Tax Schedule record, I see that it is not officially scriptable. Nevertheless, I am able to load the record ( record.load({type: "taxschedule",id: 1}) ) and even get some data.
However, when I try update a sublist default tax code (in the nexuses sublist),
using this code ():
var taxSchedRec = record.load({type: "taxschedule",id: 1, isDynamic: true});
taxSchedRec.selectLine({
sublistId: 'nexuses',
line: 3
});
taxSchedRec.setCurrentSublistValue({
sublistId: 'nexuses',
fieldId: 'salestaxcode',
text: validTaxCodeId
});
taxSchedRec.commitLine({
sublistId: 'nexuses'
});
taxSchedRec.save();
I always receive the error:
{"type":"error.SuiteScriptError","name":"INVALID_KEY_OR_REF","message":"Invalid salestaxcode reference key
I am absolutely sure that I try to update the proper row, and also that my tax code is valid and selectable from the UI.
I tried both static and dynamic mode, as well setValue and setText methods. Nothing helped.
For the "Set up Taxes" I try to load them via N/config module.
var taxPref = config.load({type: 'taxpreferences'});
taxPref.setValue({fieldId: 'taxcode4ro', value: validTaxCodeId}); // The field should be the Default Tax code
taxPref.save();
Here, the error is always:
{"type":"error.SuiteScriptError","name":"USER_ERROR","message":"Please enter value(s) for: Default Tax Code"
So, in conclusion, I'd like to ask whether any of you has tried and managed to update those records programatically or this is not possible.
Thanks,
Nikolay Georgiev