With a client script I'm trying to set the tax cod...
# suitescript
c
With a client script I'm trying to set the tax codes since the legacy tax engine can't fulfil our needs but I'm experiencing some order issue. I'm using the fieldChanged and validateLine to set both the tax rate and tax codes, both with the ignoreFieldChange: true parameter. When I'm changing the shipping address, both are triggered and I see the lines switching like they should but after that NetSuite triggers something, what I don't now, but that resets my tax codes to the tax engine determined ones. Any ideas?
a
Should you use postsourcing event too and trigger the set of the value from there?
Always try to implement a setFieldValueIdChanged in client side because Netsuite client engine triggers tons of events. So getThe field value and set it only if different
b
i dont really recommend trying to overwrite netsuite's legacy tax codes
it doesnt really work, netsuite literally had to redesign it as a new feature to make it customization
if you still think its feasible to overwrite tax codes, consider using the taxamountoverride field, which can be used to overwrite the tax amount used by netsuite
a
I think he's not trying to override taxes but only to set the tax code field value (really common) with advanced rules. Consider also that each time a nexus will change Netsuite will reload the page loading new tax code set. So why aren't you managing the tax codev in the before load event? Are you subscribed to client change events?
c
Yeh I'm not overwriting the tax codes, I'm setting the tax code field just like you could in manually in the form. This works fine with the fieldChanged trigger and using the item field as the triggered field. So everytime I change an item or add one, the tax code gets set correctly. For this determination we've added an extra field in the shipping address which isn't related to the nexus though. If I change this field and therefore my shipping address is changed, I would like to redetermine the tax codes on every line which I do in the fieldChanged. When debugging line by line, I see the lines getting changed correctly when the fieldChanged is triggered by the shippingaddress field but after a few more extra triggers, the tax code fields are resetted to the tax engine outcome
b
my warning to you is that anything that netsuite considers to change the tax calculation will overwrite whatever tax codes you set. This could be something simple like a change in address or something complex like a script. It could even be a bug, there have been bugs in the past about netsuite replacing tax codes after transforming a record
this is the kind of customization you have to test every new release