External Forms That Return Data to Decisions (javascript simple)

Last Updated: 05/03/2018 Introduced in Version: 2.0

External Form step was designed in Decisions to interact with forms using html methods or service calls. External Form step could be found in the Flow Designer in the ToolBox under Forms[Interaction] category. This method can also pass data into external form and retrieve data from the external form.

 

Example

 

In this example we are going to use user’s input from External Form to compose and send email from Decisions’ Flow.

We begin in our Designer Folder by clicking Create Flow.

 createFlow

In the resulting pop-up window we Name our Flow and click Create to proceed to the Flow Designer.

 nameFlow

In the Flow Designer start-up window  we locate External Form step under Flows, Rules, Forms and Reports > Forms[Interaction] category select it and click Add to add it to our workspace.

 flowStarts

Int the URL options we provide URL to our External Form

 providUrlToForm

Next, in the Service Outcomes section we click Add New link to create a new outcome from our External Form Step.

addOutcome 

In the resulting pop-up window we name our outcome and create 5 variables in the Parameters box. We are going to store in these parameters data that our External Form returns to us.

Next, we click OK to save and close this pop-up window.

serviceOutcomesSecond 

 

Next, we drag Send Email step to our workspace from Communication category.

 dragSendEmail

Now we can connect all our steps. Next, from Send Email‘s options we select Show Mapping Editor to configure our Email.

 showMappingForEmail

In the Mapping Editor we connect Email to From Field, define constant email in the To Field and click Show Editor under Subject Field to edit our subject.

 showTextEditorForSubj

 

We define our Subject as follow and click OK to save and continue.

 editSubject

 

Back in the Mapping Editor we click Show Editor under Body section to create our Email’s body.

 showBoduEditor

Our body is designed as follow and it is using External Form’s outcomes…

When finished we click OK to save and continue…

 editBody

This completes our Mapping so we can save and close it.

Our flow is completed now so we click Debug Flow from 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

External Form opens in a new window… We fill it up and submit the form.

 formOpens

When we click Submit button in our External Form it triggers the function in our form that was designed to build new URL with all parameters the user provided. Next, it redirects the user to this New URL causing the Flow to continue its execution using Data that was received from the External Form. This function in the External Form implemented as following:

 In the previous piece of code variables callbackurl, flowId and stepId were initialized using Data that was sent to our External Form from the Flow in URL:

 

The flow runs to the end step with no issues. Under the Data tab in the debugger we can check data that were returned from our External Form and sent to our Send Email step.

 inputDataToSendEmailStep

When we check our Email box we can see new inbox email that should look like this:

result

Note: This will not work on in crossdomain environment. For example if Portal Base URL in format [machine name]/decisions/Primary and we try to call Form on localhost.

 

External Form used in this tutorial can be downloaded from here: ExternalFormToReturnDataToDecisions

Additional Resources