Switch Node

From PresenceWiki
Revision as of 05:59, 20 August 2015 by Rob (Talk | contribs)

(diff) ←Older revision | view current revision (diff) | Newer revision→ (diff)
Jump to: navigation, search

Switch Node

The Switch Node allows the Task Designer to create multiple excecution paths for a Task, which are executed depending on the results of tests.

Consider the following scenario:

A customer, Mr Smith, has an invoice outstanding and we want to build a Task that sends a reminder email. After retrieving his invoice details from a database, we want to make a decision based on how long the debt has been outstanding. If it is less than 15 days, we want to send a polite reminder. If it is less than 30 days a slightly more stern reminder would be in order. If it has been outstanding for longer than 30 days, our accounts department will be up in arms and so we need to start making demands.

This is where a Switch Node would be ideal. We can create three separate branches based on the information we know about the invoice, and at the end of each branch we send out the appropriately worded email:

Switch task.png

Branch Sequencing

The branches get executed in the order indicated by the number on the green icon - 1 first, 2 second, etc. You can change the order by clicking on the branch and using the + / - keys.

Switch Nodes with Multiple Records

Like the Decision Node Switch Nodes can also handle tables of Data. Rows that match the criteria set on each branch are passed through, and rows that do not are then passed for consideration to the next branch in sequence (see above tip about branch ordering).

For instance, suppose your Task is dealing not with one customer's invoice but with a list of 10 outstanding invoices retrieved from the database, each for different customers. Each invoice has an outstanding balance and a due date. Our Switch node tests the due date column to see whether it is less than 15 days, less than 30 days, or more than 30 days.

Let's say three invoices are overdue by less than 15 days. These records get passed to the "< 15 days" node for processing. Once that branch has completed, the remaining 7 records (which are greater than 15 days) are then passed to the "< 30 days" branch for consideration. If 4 records are found for this test, the remaining 3 will be sent to the "> 30 days" branch.

Creating a Swith Node

The first thing to do is to drag the "Switch" Task Element from the toolbox into your Task design view. When you drop it, you will be presented with the Switch Dialog:

Switch dialog 1.png

Switch Dialog Options

Here is an explanation of the options available in the Switch Dialog which appears when you drag a Switch Node into your task.

Carry Data Over

If this option is checked, the behaviour described above (Switch Nodes With Multiple Records) is modified. Ordinarily records that match the criteria in one Switch branch will not be passed onto the next branch in sequence. This means that records must be "either / or" but cannot be "both".

The Carry Data Over option tells Presence to instead continue passing records to the next branch, even if they have already met the criteria of the previous branch.

See Also

Task Elements > Flow Control Task Elements > Switch Node

Schedule Nodes | Decision Point Nodes | Start of Task | End of Task | Error Handler
Throw Exception | Passive Node | Log Entry | Sleep For n Seconds | While Node | Loop Node |Switch Node
Fork Execution | Join Forked Threads | Start Synch Block | End Synch Block | Event Notification Nodes

Task Elements | Resources