Share via


System Center 2012 Orchestrator – Link Conditions

Orchestrator lets you to configure conditions with Smart Links. Smart Links connect individual activities in a runbook and support precedence between two activities.

Also as soon as previous activity finishes, these links invoke next activity. Best part is you can set link conditions to determine the direction of workflow.

For example, you can monitor a folder and trigger next activity for each changed and deleted files within that folder. At this situation, you can split in two your workflow to configure separated activities for changed and deleted triggers. For example;

If monitor file activity notices a change event, then smart link will redirect entire workflow through upside activities.

If monitor file activity notices a delete event, then smart link will redirect flow through downside activities.

Look at the simple design;

http://blogs.technet.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-79-57-metablogapi/0572.image_5F00_thumb_5F00_4EFF519E.png

For such a scenario, here are the basic configuration steps;

Monitor File activity monitors C:\Test folder for

http://blogs.technet.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-79-57-metablogapi/3122.image_5F00_thumb_5F00_46BB063A.png

Changed and Deleted items.

http://blogs.technet.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-79-57-metablogapi/1462.image_5F00_thumb_5F00_3A1D3351.png

If you click the first link;

http://blogs.technet.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-79-57-metablogapi/4606.image_5F00_thumb_5F00_15C82902.png

you’ll notice that link will invoke next activity (Append Line) if Monitor File activity returns Success value. Please note that this is the default value for each Smart Link.

Include tab specifies conditions that enable data to flow to the next activity.

http://blogs.technet.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-79-57-metablogapi/3443.image_5F00_thumb_5F00_02E37F8B.png

Exclude tab specifies the conditions that cause data to be excluded from the next activity. By default if an activity fails, link will not invoke next activity.

http://blogs.technet.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-79-57-metablogapi/7737.image_5F00_thumb_5F00_3A691AAC.png

Also on Options tab you can configure link width and color. This is important for especially complex runbooks to highlight failover scenarios.

Trigger Delay sets the number of seconds that you want the smart link to wait before invoking the next step in the runbook.

http://blogs.technet.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-79-57-metablogapi/3630.image_5F00_thumb_5F00_76653694.png

In this runbook example, Append Line activity is not mandatory, you can carry changed and deleted values from monitor activity to the links directly. But I just used it to show up triggered events.

It appends a line to the C:\Status.txt file with a value of Change Type from Monitor File activity.

Publishing data is also covered in my following article:

http://blogs.technet.com/b/meamcs/archive/2012/03/09/system-center-2012-orchestrator-runbook-activities.aspx

http://blogs.technet.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-79-57-metablogapi/3124.image_5F00_thumb_5F00_032F66E6.png

Now here is the magic starts. Click to Smart link to set a custom condition.

I want to set a condition as Status.txt from Append Line activity has a line of “Changed”. This provides that link will invoke next activity (Send Event Log Message) ifthe specified condition is true.

http://blogs.technet.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-79-57-metablogapi/7840.image_5F00_thumb_5F00_4499F372.png

Same condition for other smart link. This provides that link will invoke next activity (Send Email) if specified condition is true.

 

http://blogs.technet.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-79-57-metablogapi/2541.image_5F00_thumb_5F00_7F51767B.png

So if I change any file within C:\Test folder, smart link condition will redirect flow through the upper link and send an event log.

http://blogs.technet.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-79-57-metablogapi/8321.image_5F00_thumb_5F00_11F64A66.png

Let’s test with RunBook Tester.

Monitor file checks for changed and deleted files in C:\Test

http://blogs.technet.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-79-57-metablogapi/3122.image_5F00_thumb_5F00_25DFB72F.png

I changed a file within C:\Test folder and saved it.

http://blogs.technet.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-79-57-metablogapi/0486.image_5F00_thumb_5F00_751C89B6.png

Orchestrator triggers the change and hops to the next activity.

http://blogs.technet.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-79-57-metablogapi/8321.image_5F00_thumb_5F00_0F4CCD0E.png

Append Line activity appends “Changed” string to the status.txt file.

http://blogs.technet.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-79-57-metablogapi/8321.image_5F00_thumb_5F00_36576683.png

Now only matched link condition will continue on its way.

As you see below, Send Event Log Message is invoked by the upper smart link.

http://blogs.technet.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-79-57-metablogapi/5773.image_5F00_thumb_5F00_717B1C81.png

http://blogs.technet.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-79-57-metablogapi/8726.image_5F00_thumb_5F00_2D0B0575.png

Here is the log file created by Orchestrator.

http://blogs.technet.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-79-57-metablogapi/8738.image_5F00_thumb_5F00_7601016E.png

Because filtering in smart links is based on published datas from previous activities, you can also use smart link conditions with PowerShell based runbooks.

Here is an another example. It simply reads a text file to get required links. Then it checks for links with Select-String cmdlet and directs flow to the related side. Rest of workflow is about copying files to the remote servers and deleting source downloaded files.

http://blogs.technet.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-79-57-metablogapi/6170.image_5F00_thumb_5F00_01F2CBD6.png

Read Line activity just reads two lines.

http://blogs.technet.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-79-57-metablogapi/1300.image_5F00_thumb_5F00_00CDBCEA.png

Links.txt file includes two different URL to download filea or fileb from Internet.

http://blogs.technet.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-79-57-metablogapi/4213.image_5F00_thumb_5F00_07BD49A2.png

To find out which link (FileA or FileB) is provided within txt file, I wrote a little custom PowerShell script.

It scans text file and search for DownloadfileA or DownloadFileB strings. If there is a line that includes one of those strings, (not null), StatusA or StatusB variables get filea or fileb values.

http://blogs.technet.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-79-57-metablogapi/7652.image_5F00_thumb_5F00_173035A4.png

To pass these variable values to the next activity and links, simply configure them as Published Data.

http://blogs.technet.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-79-57-metablogapi/2860.image_5F00_thumb_5F00_03732643.png

Now I can tell to my smart links that to filter only for StatusA and StatusB static values.

http://blogs.technet.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-79-57-metablogapi/4520.image_5F00_thumb_5F00_252ED907.png

http://blogs.technet.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-79-57-metablogapi/2475.image_5F00_thumb_5F00_730788BC.png

Finally, if there is a URL in Links.txt file that has a string “downloadfilea”, smart link will redirect flow through upper activities. For links that includes downloadfilea string will flow through below activities.

Before finishing blog post, final important activity is Junction. It allows you to wait for multiple branches in a runbook to complete before continuing past the junction.

http://blogs.technet.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-79-57-metablogapi/1464.image_5F00_thumb_5F00_563DEDDA.png

Junction activity can also publish data again from any branch so that downstream activities past the Junction activity can consume the data. Data from different branches than the one you selected will not be available

Anıl ERDURAN