I am trying to create a Tax Code like this: ```let...
# suitescript
m
I am trying to create a Tax Code like this:
Copy code
let taxcode = record.create({
  type: "salestaxitem",
  isDynamic: true,
});
taxcode.setText("nexuscountry", "EG");
taxcode.setValue("itemid", "VAT " + vatstr + "%");
taxcode.setValue("description", vatstr + "%");
taxcode.setValue("rate", vatstr + "%");
taxcode.setValue("subsidiary", "10");
taxcode.setValue("taxagency", "16612"); 
taxcode.setValue("taxtype", "1"); // VAT_EG
taxcode.setValue("service", true);
taxcode.setValue("export", true);
taxcode.setText("available", "BOTH");
taxcodeID = taxcode.save();
But I am getting an unexpected error without any useful details
Copy code
Error at suitescript/resources/javascript/record/recordImpl.js:40:12 at Function.createRecord_raw (suitescript/resources/javascript/record/recordImpl.js:38:24) at suitescript/resources/javascript/record/recordImpl.js:26:29 at Object.createRecord (suitescript/resources/javascript/record/recordImpl.js:24:24) at <http://Object.post|Object.post> (/SuiteBundles/Bundle 364366/rl_salesorder_ns_sync.js:919:32)
Something a little bit weird, is that, the line 919 is the
create()
line, not
save()
Is creating tax codes programmatically allowed?
s
Permissions?
m
Permissions are set to Full on
Tax Records
under
Lists
I guess it is not allowed to create one using scripts.
s
Try record.Type.SALES_TAX_ITEM
m
it is
SALES_TAX_ITEM
but not allowed with creation
if you tried to search
SALES_TAX_ITEM
for the first time, you will get an error that you have to set list permission for tax records. I am not sure if they are the same thing.
b
create a tax code in the ui
any url parameters used while creating the tax item are default values you need to set in script
otherwise you get the generic rate advice, use setValue with a number, setText with a string
m
wow man, you are the best it works after I did this
Copy code
let taxcode = record.create({
  type: record.Type.SALES_TAX_ITEM,
  isDynamic: true,
  defaultValues: {
    nexuscountry: "EG",
  },
});
thanks very much 🙏