Hrm ```afterSubmit(context) { const statusPrev...
# suitescript
b
Hrm
Copy code
afterSubmit(context) {
    const statusPrevious = context.oldRecord?.getValue({ fieldId: "status" });
    const statusNew = context.newRecord.getValue({ fieldId: "status" });
    log.audit('afterSubmit', JSON.stringify({ statusPrevious, statusNew }));
}
statusPrevious
and
statusNew
are the same value in the afterSubmit, even though I'm changing the fulfillment from Packed -> Shipped 🤔
e
Yes I've observed this behavior in transactions before; the status won't actually change until everything else has settled, which is frustrating. FWIW you don't need to
JSON.stringify
an Object you pass to a
log
method; it will do that automatically for you.
b
Thanks for the json tip
✅ 1
I think I've found a work around to not use
oldRecord
Copy code
const statusNew = context.newRecord.getValue({ fieldId: "shipstatus" });
const statusPrevious = context.newRecord.getValue({ fieldId: "originalshipstatus" });
e
Is there a
shipped
event type instead?
✅ 1
b
originalshipstatus
isn't really documented that I can tell though. But holds the value I want
e
maybe
context.type === context.UserEventType.SHIP
will get you the detection you need
b
Yea, thats a weird one. That is if they click the "Ship" button in the UI. I'm good in that case. But they can alternatively change the status via edit, and then selected the status in the dropdown. In which case it is an "edit" event.
I think I am squared away now. Thanks for the assist.
✅ 1