Hi Everyone, how can I use executeMacro function i...
# suitescript
s
Hi Everyone, how can I use executeMacro function in suitescript? define(['N/record'],function(record)){ function beforeSubmitTax(context) { var record = context.newRecord; var externalTax = record.getValue({ fieldId: 'custbody_tj_external_tax_amount' }); log.debug('Sales Representative: '+externalTax); if(externalTax> 0.00) { record.executeMacro({id:'calculateTax'}); } } return{ beforeSubmit:beforeSubmitTax }; };
b
i dont think calculateTax does anything for a server side script
taxes are automatically calculated when a transaction is saved
that said, i think your syntax is correct\
s
I also used this function in client script but did not work
can you please send me a sample code?
b
its nothing interesting, just use currentRecord instead of record to calculate taxes for the currentRecord
keep in mind that the macro only works with SuiteTax
s
yes suiteTax is enable
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 }; });
I got the error message: currentRecord.executeMacro is not a function
b
make a distinction between the currentRecord module and the CurrentRecord object
in your code,
currentRecord
is the module
record
is the object
you want to do
Copy code
record.executeMacro({id:'calculateTax'});
it also why you don't name variables record or currentRecord, those are common names for modules
s
Thank You So Much