Client Formulas & Workflow Action Scripts
Upon completion of this module, you will be able to:
SuiteScript formulas use JavaScript and SuiteScript API functions configured on client triggers. They complement SQL formulas by enabling client-side processing.
Only SuiteScript 1.0 formulas are supported on client triggers. SuiteScript 2.0 functions are NOT supported except as external scripts (Suitelets, User Event Scripts, Workflow Action Scripts). You cannot invoke 1.0 scripts from 2.0 scripts.
| Function | Purpose |
|---|---|
| nlapiGetFieldValue('fieldId') | Get field value |
| nlapiSetFieldValue('fieldId', value) | Set field value |
| nlapiGetFieldText('fieldId') | Get display text of list field |
| nlapiLookupField(type, id, fields) | Look up field value on another record |
| nlapiGetUser() | Get current user's internal ID |
| nlapiGetRole() | Get current user's role ID |
Validate rating code is less than 10 characters:
If you configure a SuiteScript 1.0 formula on a server trigger, it will be ignored and show "ERROR: Invalid expression" in the log. The warning indicates unrecognizable code—the record submit still completes.
What happens when you need to perform an action not supported by standard SuiteFlow actions? This is where Workflow Action Scripts extend SuiteFlow through code.
Complex calculations, external integrations, advanced record manipulation, custom notifications, sublist processing beyond standard actions.
| Property | Description |
|---|---|
| scriptContext.newRecord | The record being processed |
| scriptContext.oldRecord | Previous version of record (on edit) |
| scriptContext.workflowId | Internal ID of the workflow |
| scriptContext.type | Event type (create, edit, etc.) |
In the workflow designer:
Workflow Action Scripts can return values that are stored in workflow fields or used by transition conditions. Define the return type in the script deployment.
| Aspect | SQL Formulas | SuiteScript Formulas |
|---|---|---|
| Trigger Type | Server triggers | Client triggers |
| Execution Location | NetSuite server/database | User's browser |
| Field Reference | {field_id} | 'field_id' in API calls |
| API Version | N/A (SQL) | SuiteScript 1.0 only |
| Best For | Database operations, calculations | UI interactions, client validation |