Scenario
Client script functions can be invoked by any Workflow Action scripts that support client-based triggers (e.g. Before User Edit, After Field Edit, etc.). These functions must be issued on the Custom Formula portion of the action.
Below is an example to demonstrate how this is done. This requires basic SuiteScript and Workflow knowledge.
Below is an example to demonstrate how this is done. This requires basic SuiteScript and Workflow knowledge.
Solution
-
Create a JavaScript file with the following codes:
Note: The above function will be called by the Workflow on Step 5.4.function sayHello(s) { alert('Hello ' + s); /* * return true|false line is required to allow/disallow the workflow action to execute. * Condition will treat the function returned false if this line is omitted. * Thus, Workflow Action (e.g. Set Field Value) will not execute */ return true; }
-
Navigate to Customization > Scripting > Scripts > New
- Click on the + logo beside the Script File Popup List
- Select the JavaScript file on the File Popup Window and click on Save
- Under Deployments tab, add the record (Applies To column) script & workflow must be applied to (For this example, Customer record is used and click on Save)
- Navigate to Customization > Workflows > Workflow > New
-
Basic Information:
-
Name: Enter Name
Example: Enter Customer Workflow - Record Type: Select Customer
- Sub Types: Select Customer
- Execute as Admin: Enter Checkmark
- Release Status: Select Released
-
Name: Enter Name
-
Event Definition:
- On Create: Enter Checkmark
- On View or Update: Enter Checkmark
- Click Save
- Click State 1
- Bottom right corner: Click New Action
- Click Set Field Value
-
Basic Information:
- Trigger On: Select Before User Edit
- Event Types: Select Create
- Context: Select User Interface
- Triggering Client Fields: Select Memo
-
Condition:
- Select Formula
- Formula: Enter sayHello(nlapiGetFieldValue('companyname'))
- Triggering Client Fields: Select Memo
- Parameters:
- Field: Select Account
- Click Save