How Do I Iterate on a Series of Values? (Magic xpi 3.x)
There are three different ways to iterate on a series of values in Magic xpi:
-
Auto repeat
-
GoTo
-
Call Flow
You define this option in the Flow Properties dialog box. Auto repeat determines whether the Server should invoke the flow again when the last flow component in the flow is completed. You can use this functionality to create a loop effect.
In your flow, you can indicate which component should be executed when the execution of one branch is complete. You can do this by using Magic xpi’s GoTo command. To use the GoTo command:
-
Select the component that you want to go from.
-
Right-click and select GoTo.
-
Select the component you want to go to.
-
Magic xpi makes the connection.
When you complete these steps, Magic xpi displays a dashed line pointing to the component to be executed next.
Note:
|
You can only use the GoTo command:
|
|
This is an option available in the Data Mapper Service as part of a Destination definition. You can use Call Flow to create a number of loops according to the number of times the flow is called by the data from the data Source.
This example assumes that you receive orders from customers in XML format. The XML file contains all the items and the quantities required. Each order may contain a different number of items and you want to set up a mechanism to check the overall stock availability for the orders.
-
Create two new flows: FlowA and FlowB.
-
Add two new flow variables to FlowB: F_Items and F_Amount.
-
Drag a Data Mapper Service to FlowA.
-
Click Configuration to open the Source/Destination Management dialog box.
-
Create an XML Source. Click Properties to open the Source properties dialog box and configure your XML Source.
-
In the Destination area, create a new Call Flow Destination.
-
Click Properties to open the Destination properties dialog box and select FlowB. Click OK to return to the Source/Destination Management dialog box.
-
Click Map to open the Data Mapper screen.
-
Map the values from the XML file to the two flow variables.
-
Map the Source compound element to the flow name in the Destination column.
This results in the second flow being invoked a number of times, corresponding to the number of items contained in the order.