Script Form Step for External Forms
  • 26 Mar 2021
  • 1 Minute to read
  • Dark
    Light

Script Form Step for External Forms

  • Dark
    Light

Article Summary

Overview

The Script Form step was designed to perform additional JavaScript commands before processing an External Form. 

JavaScript commands are configured in the Properties tab of the Script Form step. 

This article demonstrates how to use the Script Form step to show the current user Email before the XML of the External Form is exposed, by using a simple line of JavaScript.

The step will attempt to reference a localhost environment, so the PortalBaseURL must be localhost/decisions/Primary for this example.

Example

  1. From a Designer Project in the Decisions Studio, select the CREATE FLOW button on the Global Action Bar, then select Flow, provide a Name, and click CREATE.
  2. From the FORMS [INTERACTION] category of the Toolbox tab, attach a Script Form step to the Start step.
  3. Navigate to the Script Form step's Properties tab; under SERVICE DEFINITION > Service Name, provide a Name that reflects the purpose of the Form (for example "Show Current Email"), then under Service Outcomes, click ADD. 
  4. From the Add Service Outcomes window, under OUTCOME NAME > Name, provide a name that reflects the Outcome path; input "Done". Then click OK.
  5. Connect the Done path to the End step, then navigate back to the Properties of the Script Form step. Under SCRIPT > Script Data [NVelocity], provide the following Javascript line, alert ("Current user email is: ${Email}"); .
    The default Script Source option used is NVelocity which allows the user to manually write the Script.
    Alternately, users have the option to map the Javascript from Flow data via the Data option.

    The alert() method is a Javascript message type that uses NVelocity syntax to create a token for the value defined within ${} (in this example Email), as well as an Input for the step in the Flow Designer. This script allows the data to be mapped dynamically.

  6. Deselect then reselect the Script Form to allow the Email Input to appear; under Properties > INPUTS,  Select From Flow map Flow Data.CurrentUserEmail to Email. Then, from the top of the Properties tab, click View Integration Detail

  7. From the View Integration Details screen, Copy the text under Complete via Get.

  8. Navigate back to the Flow and Paste the text from the Integrations Page, into the Script Data box underneath the previously added Javascript.

  9. Save the Flow, then if desired, close via X.



Debug

  1. From the Flow Designer, select the Debug link from the top action bar.
  2. Click START DEBUGGING.
    The Flow will run, a new tab will open and display an Alert message containing the current user email.
  3. Click OK on the Alert message. 
    If successfully configured, the window will now display the XML Integration Details for the Form.




Was this article helpful?

What's Next