after calling the calculateTax macro, I still get ...
# ask-stanley-ai
b
after calling the calculateTax macro, I still get To apply amounts to transaction properly, please press Preview Tax button first."
c
AI generated answer (using internal Slack threads):
Based on the conversations, it seems that you are trying to calculate tax using the
executeMacro
function in SuiteScript before submitting a record. However, it's important to note that the
executeMacro
function may not work as expected in a server-side script. The tax is usually calculated automatically when a transaction is saved. If you are trying to calculate tax before submitting a record, you might want to consider doing this operation after the record has been saved. This is because before the record is submitted, the creation of the record could potentially fail, and certain fields might not be available. Here is a sample code snippet that was shared in the conversation:
Copy code
javascript
define(['N/currentRecord'],function(currentRecord){
    function beforeSubmitTax(context)
    {
        var record = context.currentRecord;
        // var externalTax = record.getValue({
            // fieldId: 'custbody_tj_external_tax_amount'
        // });
        // log.debug('External Tax: '+externalTax);
        // if(externalTax> 0.00)
        // {
            currentRecord.executeMacro({id:'calculateTax'});
        //}
    }
    return{
        postSourcing:beforeSubmitTax
    };
});
However, it's important to note that there was an error message stating that
currentRecord.executeMacro
is not a function. This is because there is a distinction between the
currentRecord
module and the
CurrentRecord
object. In the code,
currentRecord
is the module and
record
is the object. You should use
record.executeMacro({id:'calculateTax'});
. ****** Disclaimer: This response was generated by an artificial intelligence assistant based on previous conversations from multiple Slack channels, and may contain inaccuracies or mistakes. ******
Slack thread 1: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.840635598
Slack thread 2: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.837635398
Slack thread 3: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.822624743
Please provide your feedback on this answer.