afterSubmit(context)

Description

Defines the function that is executed after a record is submitted.

The afterSubmit operation is useful for performing any actions that need to occur following a write operation on a record. Examples of these actions include email notification, browser redirect, creation of dependent records, and synchronization with an external system.

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.

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

  • Asynchronous afterSubmit user events are only supported during webstore checkout.

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)

  • dropship (for purchase orders with items specified as “drop ship”)

  • specialorder (for purchase orders with items specified as “special order”)

  • orderitems (for purchase orders with items specified as “order item”)

  • paybills (use this type to trigger afterSubmit user events for Vendor Payments from the Pay Bill page. Note that no sublist line item information will be available. Users must do a lookup/search to access line item values.)

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 in read-only mode. To edit a record, use the record.load(options) method to load the newly submitted record. Make changes, and submit the record again.

Version 2015 Release 2

context.oldRecord

record.Record | null

required if context.UserEventType is not equal to CREATE

The old record (previous state of the record) in read-only mode.

This parameter is empty when the context.UserEventType is set to CREATE (new 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 afterSubmit entry point, see SuiteScript 2.x User Event Script Sample.

Related Topics

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

General Notices