- 07 Jun 2022
- 6 Minutes to read
- Print
- DarkLight
Wait On External System
- Updated on 07 Jun 2022
- 6 Minutes to read
- Print
- DarkLight
Overview
This tutorial demonstrates how to use the Wait On External System step in Decisions. This step is an Assigned Form for the External System (Service, External Database, etc.). This step monitors the External System, and when the desired condition is met, continues Flow execution on the Defined Outcome Path.
Example
In this example, use the Wait On External System step to monitor an External Database (Customers table in Northwind database). If a new Customer is added to the table, the Flow will stop monitoring External Table, send an email to notify that a 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. The default Decisions database or integration with another database may be used. For more information on integrating a database, see Integrating an External Database with a Flow.
Next, navigate to the Designer Folder and select Create Flow on the Folder Actions Panel.
In the resulting window name the Flow and select 'Create' to proceed to the Flow Designer.
In the Flow Designer, add Get all from dbo.Customers step from Integrations > My Integrations > Database > Northwind (Database) > dbo.Customers (Table) category.
Then, connect the Failed outcome from Get all from dbo.Customers step to the End step in the Flow. Set Limit Count Inputs to Ignore.
On the Done outcome from the Get all from dbo.Customers step add Wait On External System step from Integrations > All Integrations category.
Next, set up the Wait On External System step. Configure Service Definition Settings. Leave the Generate Service check-box unchecked.
Then, select Add New link to Expose Data On Service for the Wait On External step to be able to operate with data from the Flow.
In the resulting window name the Data and pick Type. In this example expose Results from the Get all from dbo.Customers step, therefore pick Northwind_dboCustomers type and check Is List and Can Be Null check-boxes. Select 'Ok' to save and continue.
Wait On External System step has a similar behavior as an External Form. By selecting the View Integration Details link there is information on how to integrate with this Service.
Then, set up Timer Settings. First, select Add New under Scenarios [Additional Outcomes for AutoComplete] . Each of these Scenarios will be an End step in the AutoComplete Flow for this step.
In the resulting window name the Scenario.
Next, select Add New under Parameters. These Parameters are going to be AutoComplete Flow Outcome Data from this Scenario (Outcome Path). Name the Parameter and define its Type as Northwind_dboCustomers. This will be a single Customer that will be added to the Customer database. This will be used later in the main Flow. When finished select 'Ok' to save and close this window.
Back to Wait On External System settings, define Check Time Span. This Time Span will be used by the step to monitor the External System. In this example set it to check every 15 seconds.
Next, in the Inputs Section for the Customers Input Select Value of the Customers_Result from Get all from dbo.Customers step.
Finally, select the 'Edit' icon for Is Complete Flow. This Flow will monitor the External System and evaluating which outcome path the Flow should take.
Is Complete Flow opens in the Flow Designer. The Flow has two End steps. Step Not Complete (Default) and CustomerAdded (defined by us as Outcome Scenario previously in this tutorial). Build this Flow to check if a new record is added to the database and if it is, proceed on CustomerAdded outcome, and if not proceed to Step Not Complete outcome.
After Start step in the Flow add Get all from dbo.Customers step from Integrations > My Integrations > Database > Northwind (Database) > dbo.Customers (Table) category.
Then, connect the Failed outcome to the Step Not Complete End step. On the Done outcome add Greater Than Rule step from All Steps [Catalog] > Data > Numbers category.
Then, select Get all from dbo.Customers step on the work-space and set it up as follows. Ignore Limit Count input and change Output Variable Name and Custoners_Result output Name.
Then, select Greater Than step on the work-space and select Show Mapping Editor.
In the Mapping Editor 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, connect False outcome from Greater Than Rule to the Step Not Complete End step. On the True outcome, 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 add String is Not in List step from the All Steps [Catalog] >Data > Text category.
Next, select Show Mapping Editor for String is Not in List step.
In the Mapping Editor use CustomerID list from Customers_Result(Flow input) as a list value and Item.CustomerID as a value to check. When finished save and close Mapping Editor.
Then, on the True outcome from String is Not in List step add Create Data step from the Favorite Steps category.
For the Create Data step Add New Data Definition to be a Customer of Type Northwind_dboCustomers. Then, select 'Ok' to save and continue.
Next, for the Customer Input to the Create Data step Select Value of the Item outcome from the ForEach step.
Connect Done outcome from Create Data step to CustomerAdded End step in the Flow. Then, Select Value of Customer output from Create Data step to be an Output on the CustomerAdded End step in the Workflow.
Connect the rest of the Outcome Paths from the 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 the Is Complete Flow. Save it and close the Flow Designer.
Back to the Main Flow add Send Email step from Favorite Steps category on CustomerAdded outcome from Wait On External System step.
Then, select Show Mapping Editor option for Send Email step.
In the Mapping Editor define Constant From Email Address, To Email Address, and Subject. For Email Body use Text Merge.Plain Mapping type and select Show Editor.
In the Text Merge Editor use Customer Properties to compose Email Body Notification. When finished select 'Ok' to save and continue. Then, save and close Mapping Editor.
Back in the Flow Designer connect sent outcome from Send Email step back to Get all from dbo. Customers step (to continue monitoring the External Database). Failed outcome from Get all from dbo. Customers step goes to the End Step in the Flow.
This completes the Flow; select Debug 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 start to monitor the External Database and wait until the new Customer is Added.
Go to the External Database and add a new record to the Customers Database.
Back in the Flow Debugger, the Wait On External System step detects that new Customer was added to the Database and continues Flow Execution.
An Email is received notifying us that a New Customer was Added. The Flow execution goes back to Get all from dbo.Customers step and Waits On External System again.
Repeat the process as many times as needed to confirm the Wait on External System step and its Flow function as intended.