Luis Garcia
Luis Garcia

Reputation: 1

How to return context type on Save Record?

I'm probably not seeing the obvious here, but here it goes.

I have a SuiteScript 2.0 client script and I'm trying to perform an action on Save Record, only if the record is being edited. I'm able to return the context.mode on Page Init, but I'm getting undefined.

I've tried context.mode and context.type; both return undefined

function pageInit(context) {
    alert(context.mode); // returns "edit"
}

function saveRecord(context) {
    alert(context.mode); // returns "undefined"
    // alert(context.type); // returns "undefined"
}

Upvotes: 0

Views: 2209

Answers (1)

erictgrubaugh
erictgrubaugh

Reputation: 8847

The only information you get via scriptContext on a saveRecord event is a reference to the currentRecord. See the Help page for saveRecord for details.

To determine whether a record is being created or edited, you just need to check if it already has an internal ID. If scriptContext.currentRecord.id is populated, then the record is being edited; otherwise, it's being created.

Upvotes: 4

Related Questions