简体   繁体   中英

Netsuite User event script trigger before totaltax is written

I created an user event script to get taxtotal for sales order from AfterSubmit, but I am getting blank value from it. It's not processed before I receive the data, is there a way to await for the value?

async function afterSubmit(context) {
    log.debug("Start Record", context.newRecord);
    log.debug("TotalTax", context.newRecord.getValue({ fieldId: "taxtotal" }));
    if (context.type !== context.UserEventType.CREATE) return;

    const record = context.newRecord;
    if (record["type"] == "salesorder") {
      log.debug("Intial Run", record);
      
    }
  }

I am expecting an non blank value.

According to NetSuite, Async for AfterSubmit only works during Webstore Checkout? I am assuming that is the case? I haven't done Async AfterSubmits. You could try await on one of your log.debug see if it returns value? Async / Await is a promise so you will need to wait for your promise to be resolved first.

async function afterSubmit(context) {

  await log.debug("TotalTax", context.newRecord.getValue({ fieldId: "taxtotal" }));

};

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM