beforeLoad(context)

Description

Runs a function before a record loads—whenever there’s a read operation, and before the record or page is returned.

This covers things like navigating to a record in the UI, reading it via SOAP web services, or just loading a record.

You can’t use beforeLoad to source standard records. For that, use the pageInit(scriptContext) client script instead.

Notes:

  • beforeLoad user events don’t trigger when you load or access an online form.

  • You can’t update a record that’s loaded in a beforeLoad script—if you try, that logic is ignored.

  • You can update records created in beforeLoad user events, though.

  • Attaching or detaching a child custom record 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

This is the HTTP request info sent by the browser. If a server triggers the event, you won’t see this value.

Version 2015 Release 2

context.type

string

required

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

The type matches any value in the context.UserEventType enum.

You can use this parameter to branch your script logic depending on the operation type. For example, only run delete logic when type equals delete.

User event scripts should always check the type argument so you don’t run code when you shouldn’t.

Version 2015 Release 2

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

Related Topics

General Notices