Script Form Step For External Forms

Last Updated: 07/20/2016 Introduced in Verision: 2.0

Script Form Step was designed in Decisions 3.2 for doing additional work with javascript before processing External Form. This tutorial shows a simple example of how to configure and use this step in the Workflow.

 

Example:

In this example we will configure a Script Form step to show a simple pop-up alert that will display Current User Email Address. Next, we will call our Flow back to continue Flow execution.

We begin in the Designer Folder with clicking Create Flow button on the Folder Actions Panel.

createFlow

Next, we Name our Flow and click Create to proceed to the Flow Designer.

nameFlow

In the Flow Designer we add Script Form Step from the Flows, Rules, Forms and Reports > Forms [Interaction] category in the ToolBox.

addScriptForm

Script Form step configuration window pops up. First, we need to add at least one Outcome to our step. We click Add New link in the Service Outcomes section.

addServiceOutcome

 

In the resulting window, we name our outcome. If needed, we can Add Parameters that will be passed back from this step. Click Ok when finished.

defineOutcome

 

Next, we can configure if we need System to generate service for this step by checking/unchecking Generate Service checkbox.

generateServiceCheck

 

If we need to pass Data to this step we can Add Input Data in the Expose Data On Service section.

exposeData

 

Finally, we have two options for the Script Source: Data (to pass script data to the step), and NVelocity (to type script manually). In this example we use NVelocity Script Source.

scriptSource

 

Next, in the Script Data [NVelocity] we type our javascript. In this example we simply use alert() method. Mention, in the message to display using alert() method we create a token for Email using NVelocity syntax. This makes our javascript message dynamic. We click Done to close Script Form Step configuration window.

writeScript

 

Next, we add a Show Popup step from the Favorite Steps category.

addShowPopUp

In the resulting window we configure Subject and Message for our pop-up. And, click Add.

configureShowPopUp

Then, we select Script Form step on the workspace and Step Information Layer pops up. We locate inputs for Email variable that we defined in our script, define its data Mapping Type as Select Value, and using Path picker we select CurrentUserEmail from Flow Data category.

mapEmail

 

Note: Script Form step does not continue Flow execution automatically. It will wait on the External Form to finish its work and call back to Flow. To learn how can we call back to the Flow and continue execution on the desirable outcome from Script Form step, we click View Integration Details.

viewInegrationDetails

 

Integration Details page opens in a new window. We copy a javascript for Complete via Get. Then, we return back to our Script Form step configurations.

integrationDetails

We paste Complete via Get javascript underneath our javascript in Script Data [NVelocity] box. Close Script Form step configurations.

editedScript

 

Next, we connect steps in our Flow as following and click Debug Flow link on the top panel of the Flow Designer to test our Flow.

Note that in Decisions version 3.5 and above, you’ll need to click Test Flow to access the Debugger.
3.5 Test Flow Shot

debugFlow

After we launch Debugger, new Tab in our browser opens. Defined javascript is being executed on this Default Script Form page. We can see that Alert message pops up with Current User Email. We click OK. This triggers the rest of our javascript to be executed.

alertPoppedUp

We return to the Debugger and observe our Show Popup step in action. Notification pops up and Flow is being terminated.

notificationPoppedUp

If we switch to the Diagram Tab in the Debugger, we can confirm that our Flow ran to the End Step with no errors.

flowCompleted

 

Note: This will not work on in crossdomain environment. For example if Portal Base URL in format [machine name]/decisions/Primary/ – this will not work because Default Script Form tries to call localhost/decisions/Primary

Additional Resources