Preview Tax Button Error

By in , ,
680
Preview Tax Button Error

Different clients have all different kinds of requirements. Sometimes clients uncover that there is a problem or issue happening with their transactions such as credit memos, sales orders, invoices, and/or payments. When the business identifies the issue, they reach out to their internal EBA support team and say, for example, “We have 2 million records that need to be corrected and this includes transactions from the last 12 months.”

 

As a developer / technical consultant, you might have received this kind of requirement before. The developer will start writing a script that will update the respective transactions for a specific update, but then you encounter this error:  “To apply amounts to transaction properly, please press Preview Tax button first”.

This is the error that you’ll get:

{“type”: “error.SuiteScriptError”, “name”: “USER_ERROR”, “message”: “To apply amounts to transaction properly, please press Preview Tax button first.”

Common first steps from here are searching SuiteAnswers, Google, and NetSuite professional forums. Respective users will often ask “does this instance have SuiteTax Bundle installed? Bla Bla Bla… ” nothing may work. You will find multiple solutions on how to fix this in the UI, but you can not go back and say to the client – let’s fix this in the UI manually for thousands/millions of records. You will need to find a solution that will allow you to make these updates in bulk.

 

In NetSuite > SuiteScript 2.0 > N/record Module there is something called Action and Macro APIs.

For more info: https://docs.oracle.com/en/cloud/saas/netsuite/ns-online-help/section_1509640242.html

Record macros provide an automated way to execute business logic on a record as it is edited. Changes that the execution of a macro API makes to a record are not persisted until the record is saved. An example use case for a recorded macro is a preview of the calculated tax amount for a sales order’s items. This macro API executes after items are entered on a sales order. It results in the display of the calculated tax amount on the sales order. However, the tax amount is not saved until the record is saved. A macro API is applied only to one single record at a time. After changes to the record are saved, changes to other dependent records may occur as a result.

 

The following sample code shows you how to call a calculateTax macro on a sales order record (or any transaction in NS). The record must be created or loaded in dynamic mode to execute a macro on a record. Note that the SuiteTax feature must be enabled to successfully execute the macro used in this sample.

Solution : record.executeMacro({ ‘id’:’calculateTax’ }); 

Additional Resources

1. SuiteBilling Nuances

Leave a reply

Your email address will not be published. Required fields are marked *