When adding items to a transaction via a User Event Script or using Add Multiple in the UI, the HSN Code is not automatically sourced. This is a known limitation and considered an enhancement request.
Attempting to manually set the HSN Code within a User Event Script and then saving the record will result in the following error:
“Tax Calculation Plugin error: No applicable tax rule was found for this transaction.”
Solution: Suitelet-Based HSN Code Assignment
To resolve this, implement the following approach:
- Use a custom flag field on the record to control the flow.
- In the
afterSubmitevent of the User Event Script, invoke a Suitelet to set the HSN Code. Unlike User Event Scripts, Suitelets can successfully update the HSN Code without triggering the tax plugin error. - The flag helps prevent infinite loops:
- The Suitelet sets the flag to
trueafter updating the HSN Code. - In the
beforeLoadevent, reset the flag tofalsewhenever the record is edited manually.
This ensures the HSN Code is set correctly while maintaining system stability and avoiding recursive execution.