Hello, has anyone tried using the record.executeMa...
# suitescript
t
Hello, has anyone tried using the record.executeMacro({id:'calculateTax'});? I am having his error says "details": "Error: Static Context is not initialized", Im not sure I quite understand this. this is my code
Copy code
const invoiceRec = record.load({
                                    type: record.Type.INVOICE,
                                    id: internalId,
                                    isDynamic: false,
                            });

                            const itemCount = invoiceRec.getLineCount({sublistId: 'item'});

                            if (itemCount == 1) {

                                    log.debug({
                                            title: 'getsublist equal to 1',
                                            details: `0`
                                    });

                                    invoiceRec.setSublistValue({
                                            sublistId: 'item',
                                            fieldId: 'taxcode',
                                            line: 0,
                                            value: -7,
                                            // ignoreFieldChange: true
                                    });

                            }

                            invoiceRec.save();

                            const invoiceRecButton = record.load({
                                    type: record.Type.INVOICE,
                                    id: internalId,
                                    isDynamic: true,
                            });

                            const macros = invoiceRecButton.getMacros();

                            log.debug({
                                    title: 'InvoiceMR2',
                                    details: `macros: ${JSON.stringify(macros)}`
                            });

                            if ('calculateTax' in macros) {
                                    // macros.calculateTax();
                                    invoiceRecButton.executeMacro({ id:'calculateTax' });
                            }

                            invoiceRecButton.save();
g
change isDynamic = true,
👍 1
t
Oh I forgot to update this. Yes that resolve my problem 🙂