We have seen how Decision stages are used to create alternate paths in a Process. If you have any programming knowledge, you may like to relate a Decision stage as to an IF THEN ELSE statement. The expressions we have looked at have been very simple, but they can become complex.
3.1. Decisions
Exercise 3.1.1 Validation Decision
A Decision can be used to check the value of a Data Item in order to decide which way a Process should go. Return to the First Process diagram from the previous exercises and follow these steps:
 Drag the End stage down to make a gap under the Calculation stage.
 Add a Decision after the Calculation and name it Is Z Valid?.
 Set the expression in the Decision to check if Z is negative or positive.
 Tip: A negative number is less than zero.
 Link the Calculation stage to the new Decision stage.
 Tip: Rather than deleting the existing link connecting the Calculation to the End, just draw a new link to the Decision and the old one will be removed automatically.
 Add a second End stage and link the Decision stage to the two End stages (it doesn’t matter which End stages the Yes and No branches of the Decision link to).
The Process should now look similar to this:

BulePrism进阶教程-3. Process Flow

 Press “Reset” and “Go”. Notice which path the Process follows and which End stage it stops at.
 Change the Calculation expression to [Z]-([X]*[Y]).
 Press “Reset” and “Go”. The Process should now stop at the other End stage.
 Save and Close the First Process diagram.

3.2. Circular Paths
The basic principle of Blue Prism is to automate repetitive work, and as such Process will probably need to repeat some steps over and over again. So far we have only looked at simplistic, linear paths but the reality is that we will want to create diagrams that follow some sort of circular path.
Although most stages have only one outbound link, there is no limit to the number of inbound links a stage can have. This means that a stage can be approached from more than one direction.
Exercise 3.2.1 Circular Paths
A common example of circular paths is to have a looping diagram with a Decision controlling the number of times the logic will flow around the circuit.
 Create a new Process named Circular Path Exercises.
 Add a Data Item named Loop Count with data type number and initial value 0.
 Add another Data Item named Max Loops with data type number and initial value 5.
 Add a Calculation that will increase the value of Loop Count by 1.
 Tip: Remember the “Store In” Data Item can also play a part in the expression.
 Add a Decision that compares Loop Count with Max Loops.
 Tip: Use any of the standard notation for “equals” (=), “less than” (<), or “greater than” (>) to compare values.
 Link the Decision back up to the Calculation and down to the End.
 Tip: Use Anchor stages to link around corners.
Your diagram should end up looking something like this:

BulePrism进阶教程-3. Process Flow

3.3. Controlling Play
You may have noticed when pressing the Go button that the default “running speed” is fairly slow. This can be changed using the drop-down sliding adjuster, just to the right of the Go button. Increasing the speed can be useful when working through multiple iterations.

BulePrism进阶教程-3. Process Flow

Figure 15: Debug Speed Adjuster
A running Process can also be paused and resumed using the buttons on the toolbar. And as an alternative to continuous play, a Process can be run one stage at a time. This is known as stepping.
To step though the process one stage at a time click the step buttonBulePrism进阶教程-3. Process Flow

Exercise 3.3.1 Controlling Play/Running at Speed
 Change the Circular Path Exercises Process so it will do 20 iterations.
 Set the running speed to maximum.
 Press “Reset” and “Go”.
 Experiment by pausing, stepping, and resuming the Process.
Exercise 3.3.2 Changing Current Value
 Change the Circular Path Exercises Process to do 100 iterations.
 Run at maximum speed.
 Pause the Process and modify the Current Value of one of the Data Items so that the Decision will route the flow to the End stage.
 Tip: Think about how the Decision determines how the flow should stop going around the loop.
3.4. Set Next Stage
A running process can be paused and made to jump directly to another position.
Exercise 3.4.1 Set Next Stage
 Run the Circular Path Exercises Process again and pause somewhere in the middle.
 Right-click on the End stage and select Set Next Stage from the mouse menu.
 Press “Go”.
When running a Process, this feature can be very useful for skipping past a section of a diagram. However, be aware that Set Next Stage may have an undesired effect if the new position contains logic, dependent on the section that was skipped over.
Set Next Stage is also useful in “replaying” sections of a diagram by jumping back to an earlier position.

Key Point

Set Next Stage does not “fast-forward” or “rewind” but simply “jumps” forward or back.

3.5. Breakpoints
A process can be set to pause on a specific stage if necessary.
Exercise 3.5.1 Breakpoint
 Right-click on the Calculation in the Circular Path Exercises Process.
 Select “Breakpoint” from the mouse menu. Notice the red highlight around the Calculation

BulePrism进阶教程-3. Process Flow

Figure 16: Breakpoint Stage
 Rerun the Process and see how it pauses at the Breakpoint and displays a message.

BulePrism进阶教程-3. Process Flow

Figure 17: Breakpoint Message
 Continue running by pressing Go (or by closing the message and then pressing “Go”).
 When the Process pauses at the Breakpoint again, close the message, right-click on the Calculation, and select from the mouse menu to remove the Breakpoint.
 Continue running by pressing “Go”.
 Pause the Process, save, and then close Circular Path Exercises.
Key Point

Breakpoints only take effect when the diagram is open. In the Production environment, the diagram is not displayed when a Process runs and Breakpoints are ignored.
3.6. Collections and Loops
The Data Items we’ve used so far have been used to hold single values but there is also way to hold multiple pieces of data together.
 Set Next Stage does not “fast-forward” or “rewind” but simply “jumps” forward or back.
 Breakpoints only take effect when the diagram is open. In the Production environment, the diagram is not displayed when a Process runs and Breakpoints are ignored.

A Collection is a type of Data Item that can hold multiple values arranged like a table with columns and rows, similar to an Excel spreadsheet.
Collection data are accessed one row at a time using a Loop stage to move forward through the rows. Again, a programming comparison can be made by likening a Collection to an array and a Loop stage with a “for each” statement.
Exercise 3.6.1 Collections and Loops
 Open the example Process named Collection Example.
 Find the Collection named My Orders and double click to open the properties window.
 See how the Collection has column definitions for Field Name and Type, plus tabs for rows of Initial Values and Current Values.

BulePrism进阶教程-3. Process Flow

Figure 18: Collection Toolbar Button

BulePrism进阶教程-3. Process Flow

Figure 19: Collection Stage

BulePrism进阶教程-3. Process Flow

Figure 20: Collection Properties (Fields Tab)

BulePrism进阶教程-3. Process Flow

Figure 21: Collection Properties (Initial Values Tab)
 Close the properties window.
 Add a Loop stage to the diagram.

BulePrism进阶教程-3. Process Flow

Figure 22: Loop Toolbar Button
 Notice that, unlike most stages, the Loop stage has two parts.

BulePrism进阶教程-3. Process Flow

Figure 23: Loop Stage

Open the properties of the Loop start.

BulePrism进阶教程-3. Process Flow

Figure 24: Loop Properties

 Set the Collection drop-down to My Orders.
 Add a Note stage between the start and end of the Loop (we will look at what Notes are for later in the course).
 Add links from the Start stage to the top of the Loop, to the Note, to the bottom of the Loop, and then to the End.
The resulting Process will probably look similar to the diagram below:

BulePrism进阶教程-3. Process Flow

 Run the Process.
 See how the Process turns back on itself as it loops through the Collection.
 Notice also how the text in the Collection Data Item changes as the Process runs.
Exercise 3.6.2 Collections in Expressions
Collection fields can be used as part of an expression. For instance, we can perform Calculations using the Collection data with a Calculation stage positioned between the start and end of the Loop. As the Loop iterates through the Collection, each row is made available to the Calculation and can be used in the Calculation’s expression.
To include a Collection field in an expression, we use what is known as dot notation. All this means is that both the Collection name and the field name must be included in the expression, and to do this you simply together using a full stop, for example [My Orders.Quantity].
Key Point

Dot notation is used to refer to Collection fields, i.e., “Collection Name.Field Name”

Exercise 3.6.3 Calculating the Total Quantity
In this exercise, we will continue with the Collection Example Process and add up all the Quantity values in the My Orders Collection.
 Add a number Data Item named Total Quantity and set the initial value to zero.
 Delete the Note and in its place put a Calculation stage named Add Quantities.
 In the Calculation properties, create an expression to calculate the total quantity of items.

 Tip: Find My Orders in the list of Collections on the right of the properties window and drag in the appropriate column name.
 Tip: Think of Total Quantity as the running total when the loop iterates through the rows of the Collection.
 Tip: Remember that you can use the “Store Result In” Data Item name in the expression.
Your Collection Example Process should now look similar to this:

BulePrism进阶教程-3. Process Flow

And your Calculation expression should be [My Orders.Quantity] + [Total Quantity]
Exercise 3.6.4 Finding the Earliest Order Date
Continuing with the Collection Example Process, we will now find the smallest value of Order Date in the in the My Orders Collection.
 Delete the Total Quantity Data Item and Calculation stage added in the previous exercise.
 Make space inside the loop by dragging Loop End1 and End stages downwards.
 Add a Data Item named Loop Counter with data type Number and initial value 0.
 Add a Data Item named Earliest Date with data type Date and initial value left blank.
 Add a Calculation stage named Count underneath the start of the Loop.
 Set the Calculation expression so that it will add 1 to Loop Counter.
 Add a Decision stage named First Loop? underneath the Calculation.
 Set the Decision expression to check if Loop Counter is equal to 1.
 If Loop Counter is 1, we must be on the first row of the Collection, meaning the date on that row is the earliest date so far, and we can use a Calculation stage to set the value of Earliest Date.
 If Loop Counter is not 1, we must have already moved beyond the first row and can assume that the Earliest Date Data Item contains a value.
 Add a second Decision stage named Earlier Date? Underneath the first Decision stage.
 Set the Decision expression to check if the Order Date value in the Collection row is earlier than the value in the Earliest Date Data Item.

 If the date in the Collection row is earlier, then it is now the earliest date so far and we can use a Calculation stage to change the Earliest Date Data Item.
 If the date in the Collection row is not earlier, then the Earliest Date Data Item still contains the earliest date so far and does not need to be changed.
 Tip: To move to the next row of a Collection, link to the end of the Loop, not the start. Linking to the start resets the Loop to begin from the first row of the Collection.
Your Collection Example Process should now look similar to this:

BulePrism进阶教程-3. Process Flow

Save and Close the Collection Example Process. We will look at ways to create and modify Collections later on.
3.7. Layers of Logic
Real-world processes contain large amounts of flow structures, stages, and data items and often a significant amount of space is required to arrange them.
Like other business flow diagrams, a Blue Prism Process can be spread over a series of pages arranged in a hierarchy.

BulePrism进阶教程-3. Process Flow

Figure 25: Page Hierarchy
Exercise 3.7.1 Adding a Page
 Open the Circular Path Exercises Process again.
 Right-click on the Main Page tab at the top of the diagram and select “New”.
 Accept the default name Page 1.
 Link the Start stage of the new page to the End stage.
 Go back to Main Page and add a Page Reference stage.

BulePrism进阶教程-3. Process Flow

Figure 26: Page Reference Toolbar
 When you place a new Page Reference stage on the diagram, a window will appear asking which page you want to refer to. Select Existing Page and Page 1.

BulePrism进阶教程-3. Process Flow

Figure 27: New Page Wizard

BulePrism进阶教程-3. Process Flow

Figure 28: Page Reference Stage
 Open the properties of the Page Reference stage and see that it refers to the new Page 1 page.

BulePrism进阶教程-3. Process Flow

Figure 29: Page Reference Properties
 Position the Page Reference stage so that it sits on the path looping back up to the Calculation.
 Remake the links so that the Page Reference stage is connected into the diagram.
 Limit the maximum loops to five.
 Run the Process at normal speed.
Your Circular Path Exercises Process should now look similar to the picture below:

BulePrism进阶教程-3. Process Flow

A Page Reference stage takes the Process down to the start of another page. When the end of that page is reached, the Process comes back up to the Page Reference stage that called it.

BulePrism进阶教程-3. Process Flow

Figure 30: The Logical Flow through a Page Reference Stage
Exercise 3.7.2 Nested Page References
A Process can have multiple levels of interconnected pages, i.e., “pages within pages”. This sort of hierarchical arrangement is sometimes known as nesting. Staying with the Circular Path Exercises Process, follow these steps to see how this works:
 Add another new page and as before keep with the default name Page 2.
 On the new page, link the Start stage to the End stage.
 Go to Page 1 and add a new Page Reference stage that refers to Page 2.
 Position the new Page Reference between Start and End and link the three stages together.

Go to the Main Page and run the Process again.
Exercise 3.7.3 Deleting a Page
Pages can be deleted if necessary but care must be taken with any references to a deleted page. Follow these steps to see the effect on your Circular Path Exercises Process:
 Right-click on the Page 2 tab and select Delete from the mouse menu. Answer “Yes” to the subsequent confirmation message

BulePrism进阶教程-3. Process Flow

Figure 31: Page Mouse Menu
Exercise 3.7.4 Page Mouse Menu
 Go back to Page 1 and open the properties window of the Page 2 reference. Notice that the Page drop-down is set to None – this is because the Page Reference has been orphaned

BulePrism进阶教程-3. Process Flow

Figure 32: An Orphaned Page Reference
Exercise 3.7.5 Orphaned Page Reference Stage
 Delete the orphaned Page Reference stage.
3.8. Pages for Organization
When you come to develop “real-life” Processes, you will find diagrams can become large and unwieldy, and separating the logic out on to more pages will help to keep your diagrams tidy and readable. You will almost

certainly not be working alone on a Blue Prism solution and, as with any shared document, it makes sense to keep things clear and intelligible to others.
Exercise 3.8.1 Cutting and Pasting
For this exercise, we will imagine that the logic on the Main Page Circular Path Exercises should be moved to another page so that it can be re-used.
 Delete the Page Reference from Main Page and replace it with an Anchor stage.
 Draw a selection box around everything on Main Page apart from the Start, End, and Information Box.
 Tip: Remember to select the Data Items as well as the stages.

BulePrism进阶教程-3. Process Flow

Figure 33: Selecting Stages
 Cut the selection off Main Page.
 Tip: Use either the menu Edit->Cut, CTRL+X, or the toolbar button,.
 Paste the selection onto Page 1 and link the Start and End stages.
 Go back to the Main Page and add two new Page References that both call Page 1.
 The two pages of the Circular Path Exercises Process should now look like this:

BulePrism进阶教程-3. Process Flow

 Press “Reset” and “Go” to see that the looping circuit runs is executed twice.
Save the Circular Path Exercises Process.
3.9. Review
 Set Next Stage and Breakpoint can be used when stepping through a Process.
 A circular path is a common logical structure.
 Collections are Data Items that can hold multiple pieces of data in columns and rows.
 Loop stages are used to move forward through the rows of a Collection.
 A Process diagram can run at variable speeds or be stepped through one stage at a time.
 Pages are used to break a large Process up into smaller sections.
 Pages are arranged hierarchically or nested.
 The Main Page is at the top of the hierarchy.
 A Page can reference other pages any number of times.
 A Page can be referenced by other pages any number of times.
 The exception is the Main Page, which cannot be referenced.
Blue Prism Keywords
Set Next Stage, Breakpoint, Loop, Iteration, Go, Pause, Step, Page, Page Reference, Nesting, Main Page.

相关文章: