beforeSubmit(context)

Description

Defines the function that is executed before a record is submitted; that is, prior to any write operation on the record.

Changes made to the current record in this script persist after the write operation.

The beforeSubmit event can be used to validate the submitted record, perform any restriction and permission checks, and perform any last-minute changes to the current record.

Notes:

  • The approve, cancel, and reject argument types are only available for record types such as sales orders, expense reports, timebills, purchase orders, and return authorizations.

  • Only beforeLoad and afterSubmit user event entry point functions execute on the Message record type when a message is created by an inbound email case capture. Scripts set to execute on a beforeSubmit event do not execute.

  • User Event Scripts cannot override custom field permissions. For instance, if a user’s role permissions and a custom field’s permissions differ, beforeSubmit cannot update the custom field, even if the script is set to execute as Administrator.

  • Attaching a child custom record to its parent or detaching a child custom record from its parent triggers an edit event.

This event can be used with the following context.UserEventType:

  • create

  • edit

  • xedit (inline editing; only returns the fields edited and not the full record)

  • delete

  • approve (only available for certain record types)

  • cancel (only available for certain record types)

  • reject (only available for certain record types)

  • pack (only available for certain record types, for example Item Fulfillment records)

  • ship (only available for certain record types, for example Item Fulfillment records)

  • markcomplete (specify this type for a beforeSubmit script to execute when users click Mark Complete on call and task records)

  • reassign (specify this type for a beforeSubmit script to execute when users click Grab on case records)

  • editforecast (specify this type for a beforeSubmit script to execute when users update opportunity and estimate records using the Forecast Editor)

Returns

void

Since

Version 2015 Release 2

Parameters
Note:

The context parameter is a JavaScript object.

Parameter

Type

Required / Optional

Description

Since

context.newRecord

record.Record

required

The new (or updated) record.

Version 2015 Release 2

context.oldRecord

record.Record

required

The old record (the previous state of the record).

Version 2015 Release 2

context.type

string

required

The trigger type. Use the context.UserEventType enum to set this value.

Version 2015 Release 2

For an example of the beforeSubmit entry point, see SuiteScript 2.x User Event Script Sample.

Related Topics

SuiteScript 2.x User Event Script Entry Points and API
afterSubmit(context)
beforeLoad(context)
context.UserEventType

General Notices