pageInit(scriptContext)

Important:

Client scripts only run in edit mode. If you've got a deployed client script with a pageInit entry point, it doesn't run when you view the form. It runs when you click Edit.

Description

This function runs after the page loads or when the form is reset.

You can use this function to:

  • Set default field values.

  • Turn fields on or off.

  • Change field availability or values based on the record's data.

  • Set initial field values using flags.

  • Show alerts if the loaded data is inconsistent or corrupted.

  • Get user login info and update field options or values accordingly.

  • Check that required fields for your custom code (but not necessarily required for the form) exist.

For an example, see SuiteScript Client Script Sample.

Returns

void

Since

Version 2015 Release 2

Parameters
Note:

The scriptContext parameter is a JavaScript object. NetSuite automatically sends it to your script's entry point.

Parameter

Type

Description

Since

scriptContext.currentRecord

currentRecord.CurrentRecord

The current form record.

For more information about CurrentRecord object members, see CurrentRecord Object Members.

Version 2015 Release 2

scriptContext.mode

string

The mode in which the record is being accessed. The mode can be one of these:

  • copy

  • create

  • edit

Version 2015 Release 2

For an example of the pageInit entry point, see SuiteScript Client Script Sample.

Related Topics

General Notices