Call Client Scripts from Workflow

Written by
Manuelito Macalinao
Published on
August 31, 2023 at 9:11:56 AM PDT August 31, 2023 at 9:11:56 AM PDTst, August 31, 2023 at 9:11:56 AM PDT

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.

Solution

  1. Create a JavaScript file with the following codes:
    functionsayHello(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 */returntrue;}
    Note:The above function will be called by the Workflow on Step 5.4.
  2. Navigate toCustomization>Scripting>Scripts>New
    • Click on the+logo beside theScript FilePopup List
    • Select the JavaScript file on the File Popup Window and click onSave
    • UnderDeploymentstab, add the record (Applies Tocolumn) script & workflow must be applied to (For this example,Customerrecord is used and click onSave)
  3. Navigate toCustomization>Workflows>Workflow>New
  4. Basic Information:
    • Name:EnterName
      Example:Enter
      Customer Workflow
    • Record Type:SelectCustomer
    • Sub Types:SelectCustomer
    • Execute as Admin:EnterCheckmark
    • Release Status:SelectReleased
  5. Event Definition:
    • On Create:EnterCheckmark
    • On View or Update:EnterCheckmark
  6. ClickSave
  7. ClickState 1
  8. Bottom right corner:ClickNew Action
  9. ClickSet Field Value
  10. Basic Information:
    • Trigger On:SelectBefore User Edit
    • Event Types:SelectCreate
    • Context:SelectUser Interface
    • Triggering Client Fields:SelectMemo
  11. Condition:
    • SelectFormula
    • Formula:EntersayHello(nlapiGetFieldValue('companyname'))
    • Triggering Client Fields:SelectMemo
  12. Parameters:
    • Field: SelectAccount
  13. ClickSave