Wait On External System
- Updated on 22 Jul 2016
- 7 minutes to read
This tutorial demonstrates how to use Wait On External System step in Decisions . This step is an Assigned Form for the External System (Service, External Database etc.) . This step monitors External System , and when the desired condition is met, continues Flow execution on the Defined Outcome Path .
In this example we are going to useWait On External System step to monitor External Database (Customers table in Northwind database) . If new Customer is added to the table, our Flow will stop monitoring External Table , send an Email to notify that new Customer was added to the table, and start monitoring Customers Table again.
This example assumes the Northwind database has been integrated with the Portal. For your own purposes, you can use your default Decisions database or you can integrate with another database. For more information on integrating a database, see Integrating an External Database with a Flow .
Next, we navigate to the Designer Folder and click Create Flow on the Folder Actions Panel.
In the resulting window we Name the Flow and click Create to proceed to the Flow Designer.
In the Flow Designer we add Get all from dbo.Customers step from Integrations > My Integrations > Database > Northwind (Database) > dbo.Customers (Table) category.
Then, we connect Failed outcome from Get all from dbo.Customers step to the End Step in our Flow . And, set Limit Count Inputs to Ignore .
On the Done outcome from the Get all from dbo.Customers step we add Wait On External System step from Integrations > All Integrations category.
Next, we are going to set up our Wait On External System step. First, we configure Service Definition Settings . We leave Generate Service check-box unchecked because we do not need to use this step via Service call in this example.
Then, we click Add New link to Expose Data On Service for our Wait On External Step to be able to operate with data from our Flow .
In the resulting window we Name our Data and pick Type . In this example we are going to expose Results from Get all from dbo.Customers step, therefore we pick Northwind_dboCustomers Type and checkIs List and Can Be Null check-boxes. Click Ok to save and continue.
Wait On External System step has similar behavior asExternal Form . If we click View Integration Details link we should be able to see how to integrate with this Service .
Then, we are going to set up Timer Settings . First, we Add New Scenarios [Additional Outcomes for AutoComplete] . Each of this Scenarios is going to be anEnd Step in the AutoComplete Flow for this step.
In the resulting window we Name our Scenario .
Next, we Add New Parameters . These Parameters are going to be AutoComplete Flow Outcome Data from this Scenario (Outcome Path) . We Name Parameter and define its Type (Northwind_dboCustomers) . This will be a single Customer that will be added to our Customers database. We will need to use it later in our main Flow . When finished click Ok to save and close this window.
Back to Wait On External System settings, we define Check Time Span . This Time Span will be used by the step to monitor the External System . In this example we set it to check every 15 seconds.
Next, in the Inputs Section for the Customers Input we Select Value of the Customers_Result from Get all from dbo.Customers step.
Finally, we click Edit icon for Is Complete Flow . This Flow will be monitoring our External System and evaluating which outcome path our Flow should take.
Is Complete Flow opens in the Flow Designer . We can see that our Flow has twoEnd Steps . Step Not Complete (Default) and CustomerAdded (defined by us as Outcome Scenario previously in this tutorial). We are going to build this Flow to check if a new record is added to the Database and if it is, we are going to proceed on CustomerAdded outcome, and if not we will proceed on Step Not Complete outcome.
After Start step in the Flow we add Get all from dbo.Customers step from Integrations > My Integrations > Database > Northwind (Database) > dbo.Customers (Table) category.
Then, we connect Failed outcome to the Step Not Complete End Step. On the Done outcome we add Greater Than Rule Step from All Steps [Catalog] > Data > Numbers category.
Then, we select Get all from dbo.Customers step on the work-space and set it up as following… We Ignore Limit Count input and change Output Variable Name and Custoners_Result output***Name*** .
Then, we select Greater Than step on the work-space and click Show Mapping Editor.
In the Mapping Editor we map Customer_Result New.Count (Get all from dbo.Customers in this Flow) to value1 and Customers_Result.Count (Flow input from the Main Flow) to value2 . When finished save and close Mapping Editor.
Next, we connect False outcome from Greater Than Rule to the Step Not Complete End Step . On the True outcome we add ForEach Step from Flow Management category.
In the resulting window select Pick the option Customers_Result_New as Select Value [From Flow] for ForEach Step and Data type.
Then, on the Next outcome from the ForEach Step we add String is Not in List Step from the All Steps [Catalog] >Data > Text category.
Next, we click Show Mapping Editor for String is Not in List step.
In the Mapping Editor we use CustomerID list from Customers_Result (Flow input) as a list value and Item.CustomerID as a value to check. When finished we can save and close Mapping Editor.
Then, on the True outcome from String is Not in List step we add Create Data Step from the Favorite Steps category.
For the Create Data Step we Add New Data Definition to be a Customer of Type Northwind_dboCustomers. Then, click Ok to save and continue.
Next, for the Customer Input to the Create Data Step we Select Value of the Item outcome from the ForEach Step.
We connect Done outcome from Create Data Step to CustomerAdded End Step in our Flow . Then, we Select Value of Customer output from Create Data Step to be an Output on the CustomerAdded End Step in our Workflow .
We connect the rest of the Outcome Paths from our steps as following:
- False outcome from Greater Than step to Step Not Complete End Step
- False outcome from String is Not in List step to ForEach Step
- Done outcome from the ForEach Step to CustomerAdded End Step.
This completes our Is Complete Flow . We can save it and close Flow Designer.
Back to our Main Flow we add Send Email Step from Favorite Steps category on CustomerAdded outcome from Wait On External System Step .
Then, we click Show Mapping Editor option for Send Email step.
In the Mapping Editor we define Constant From Email Address , To Email Address , and Subject . For Email Body we use Text Merge.Plain Mapping type and click Show Editor.
In the Text Merge Editor we use Customer Properties to compose Email Body Notification . When finished we click Ok to save and continue. Then, we save and close Mapping Editor.
Back in the Flow Designer we connect sent outcome from Send Email step back to Get all from dbo. Customers step (to continue monitoring our External Database) . Failed outcome from Get all from dbo. Customers step goes to the End Step in our Flow . This completes our Flow ; we can click Test Flow on the top panel of the Flow Designer to test.
Flow starts in the Debugger and stops on Wait On External System step. At this point we start to monitor our External Database and wait until new Customer is Added .
We go to ourExternal Database and Add new record to our Customers Database.
Back in the Flow Debugger our Wait On External System step detects that new Customer was added to the Database and continues Flow Execution.
And, we receive an Email notifying us that New Customer was Added .
Our Flow execution goes back to Get all from dbo.Customers step and Waits On External System again.
If we add another Customer to our Database …
Flow continues execution and we receive another Notification Email from our Flow .