afterSubmit(context)

Description

Runs the function right after a record is submitted.

Use afterSubmit for anything you want to happen after a write operation—like sending an email, redirecting a browser, creating related records, or syncing with an external system.

Notes:

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

  • Attaching or detaching a child custom record triggers an edit event.

  • Asynchronous afterSubmit user events only work during webstore checkout.

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

  • create

  • edit

  • xedit (inline editing—only returns the edited fields, 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 for Vendor Payments from the Pay Bill page. No sublist line item info will be available, so you’ll need a search or lookup for details.)

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 is read-only. To edit it, use record.load(options) to load the submitted record, make your changes, and submit it again.

Version 2015 Release 2

context.oldRecord

record.Record | null

required if context.UserEventType is not equal to CREATE

The old record (the previous version) is also read-only.

This parameter’s empty when context.UserEventType is CREATE (a new record).

Version 2015 Release 2

context.type

string

required

This is the trigger type—set it using context.UserEventType.

Version 2015 Release 2

Want an example of afterSubmit? Check out the SuiteScript 2.x User Event Script Sample.

Related Topics

General Notices