beforeSubmit(context)

Description

This function runs before a record is submitted—so before any write operation happens.

Any changes you make to the record in this script stick after the write operation.

You can use beforeSubmit to validate the record, add restrictions or permission checks, or make last-minute changes.

Notes:

  • The approve, cancel, and reject argument types only work for record types like sales orders, expense reports, timebills, purchase orders, and return authorizations.

  • Only beforeLoad and afterSubmit entry point functions run on the Message record type when a message is created by inbound email case capture—beforeSubmit scripts won't run.

  • User Event Scripts can’t override custom field permissions. So, if a user’s role permissions and a custom field’s permissions don’t match, beforeSubmit can’t update the field—even if the script’s set to run as Administrator.

  • If you attach or detach a child custom record from its parent, it triggers an edit event.

  • The context parameters for old and new records are always in standard mode. For details, see SuiteScript 2.x Standard and Dynamic Modes.

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 (how the record looked before).

Version 2015 Release 2

context.type

string

required

The trigger type—set with context.UserEventType.

Version 2015 Release 2

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

Related Topics

General Notices