Simple ASP.NET External Form Using Data From Decisions
  • Updated on 14 Aug 2014
  • 4 minutes to read
  • Print
  • Dark
    Light

Simple ASP.NET External Form Using Data From Decisions

  • Print
  • Dark
    Light

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  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 pass data from Decisions to external ASP.NET web form using POST method, and display this data as Form's Labels.
We begin with creating New Flow in the Designer Folder. Next, we Name our Flow and click Create to proceed to the Flow Designer .
2018-01-17_145137-1024x691.png

In the Flow Designer start-up window we select External Form step from Flows,Rules, Forms and Reports > Forms[Interaction] category. Click Add to add it to our flow.
2018-01-17_145407.png

Next, we locate Url options setup box in the ToolBox ... From Mapping Type dropdown we choose Constant and insert url to our external form into Value field.
Next, under Service Definition options for this step we locate Service Outcomes box and click Add New link to add new outcome from our External Form step.
2018-01-17_161935.png

In the resulting pop-up window we give our Outcome name... For this example we are not expecting any data to be returned from the external form so we are not adding any Parameters . We click Ok to save and close this pop-up window.
2018-01-17_162026.png

To send data to our form we need to populate our External Form step with data we want to send. To do this we locate Expose Data On Service box and click Add New link to add new input Parameter .
2018-01-17_162334.png

In the resulting pop-up window we provide the Name to our parameter and click Type selector to define Type for our Parameter . Next we click Ok to save and close Type picker and click Ok again to save and close our Add Expose Data On Service window.
2018-01-17_162424.png

The same way we add all Parameters that we want to send to our form. In this case all of them are String types except Age which is an Integer Type .
2018-01-17_162628.png

We can connect our steps now in the workspace. Next, from our External Form's options we choose Show Mapping Editor to populate our Parameters with actual data we want to send to the external form.
2018-01-17_163348.png

In the Mapping Editor we choose Constant type of input for all our Parameters .
Next, we can populate our Parameters with the desirable Values to send to our External Form ... When we finish we click Ok to save and close Mapping Editor .
2018-01-19_094617-1024x385.png

Mention that we can view all information about ourExternal Form step. This information is about how our Flow step can interact with the external form. To view this information choose View Integration Detail from the External Form Options . The page with detail information opens in a new window.
This completes our flow. We can click Debug Flow link 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.
2018-01-19_102948.png

Our form opens in a new window and it is populated with the information that we had sent to it.
2018-01-19_103100-1024x608.png

In this case Decisions send our Data from Flow to the External Form in URL as Key - Value pairs. This External Form was designed in ASP.NET. It is easy to parse URL that we received in our Form and use this Data to populate fields in our Form like this:

 protected void Page_Load(object sender, EventArgs e)
    {
        string firstName = Request.QueryString["FirstName"];
        string lastName = Request.QueryString["LastName"];
        string age = Request.QueryString["Age"];
        string phone = Request.QueryString["Phone"];
        string email = Request.QueryString["Email"];
        string address = Request.QueryString["Address"];

        lblFirstName.Text = Request["FirstName"];
        lblLastName.Text = Request["LastName"];
        lblAge.Text = Request["Age"];
        lblPhone.Text = Request["Phone"];
        lblEmail.Text = Request["Email"];
        lblAddress.Text = Request["Address"];
        
    }

When we submit our form our flow keeps running to the end. This is because Submit button triggers a simple method that builds a New URL using important Data that was sent to the Form from Decisions, and redirects user to this New URL that causes our Flow to Resume:

 protected void btnSend_Click(object sender, EventArgs e)
{
        string redirTo = "";
        string callbackurl = "";
        string stepId = "";
        string flowId = "";
        string otherinputs = "";
        string url = HttpContext.Current.Request.Url.Query;
        string[] pairs = url.Split('&');
        for (int i = 0; i < pairs.Length; i++)
        {
                string tmp = pairs[i];
                if (tmp.IndexOf("step") != -1) {
                stepId = tmp;
                }
                    else if (tmp.IndexOf("flow") != -1) {
                    flowId = tmp;
                    }
                        else if (tmp.IndexOf("call") != -1) {
                        callbackurl = tmp;
                        }
                            else {
                            otherinputs += tmp;
                            }
    }
        if (callbackurl.Length != 0) { 
        redirTo = "http://decisions/decisions/nosl/?action=PostCustomFormDataToFlow" +
            "&" +
            flowId
            + "&"
            + stepId +
            "&OutcomePath=Done";
        }
        Response.Redirect (redirTo);
    }

In the debugger we can see that flow ran with no errors. Additionally, we can check what data was sent to the form under Data tab in the debugger.
dataSentToForm.png

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 here: ReceiveDataASP

Was this article helpful?