beforeLoad(context)

Description

Defines the function that is executed before a record is loaded; that is, whenever a read operation occurs on a record, and prior to returning the record or page.

These operations include navigating to a record in the UI, reading a record in SOAP web services, and loading a record.

The beforeLoad event cannot be used to source standard records. Use the pageInit client script for this purpose. See pageInit(scriptContext).

Notes:

  • beforeLoad user events cannot be triggered when you load/access an online form.

  • Data cannot be manipulated for records that are loaded in beforeLoad scripts. If you attempt to update a record loaded in beforeLoad, the logic is ignored.

  • Data can be manipulated for records created in beforeLoad user events.

  • 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

  • view

  • copy

  • print

  • email

  • quick view

Returns

void

Since

Version 2015 Release 2

Parameters

Note:

The context parameter is a JavaScript object.

Parameter

Type

Required/Optional

Description

Since

context.form

serverWidget.Form

required

The current form.

Version 2015 Release 2

context.newRecord

record.Record

required

The new record (the record being loaded).

Version 2015 Release 2

context.request

http.ServerRequest

optional

The HTTP request information sent by the browser. If the event was triggered by a server action, this value is not present.

Version 2015 Release 2

context.type

string

required

The type of operation invoked by the event (the trigger type).

The type can be any of the possible values for the context.UserEventType enum.

This parameter allows the script to branch out to different logic depending on the operation type. For example, a script that includes logic to delete a record and all of its child records should only be invoked when type equals delete.

User event scripts should always check the value of the type argument to avoid indiscriminate execution.

Version 2015 Release 2

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

Related Topics

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

General Notices