Business Requirement
A typical business process that may branch to several parallel activities
On completion of the parallel activities, all lines should join up to continue processing with a single instance
Parallel activities may vary and are determined by runtime business rules (Scenario 1 & 2 following)
![clip_image002[8] clip_image002[8]](http://k2underground.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/pitchblack.metablogapi/2133.clip_5F00_image0028_5F00_thumb_5F00_63BEEEAA.gif)
Scenario 1
![clip_image004[5] clip_image004[5]](http://k2underground.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/pitchblack.metablogapi/4111.clip_5F00_image0045_5F00_thumb_5F00_6F7435DC.gif)
Scenario 2
![clip_image006[5] clip_image006[5]](http://k2underground.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/pitchblack.metablogapi/4505.clip_5F00_image0065_5F00_thumb_5F00_5B0E7051.gif)
Technical challenges
· Variable parallel activities. In this business case one (1) or more activities may execute at the same time, and is only determined during runtime execution and business logic validation.
· No code. The process is being developed by a ‘empowered’ business user who understands the business process and is able to create workflows, infopath forms and SmartObjects.
Activity Statuses
· To achieve the requirement of knowing when various independent activities completed a SmartObject is required per logical grouping
· Each activity executed in parallel is represented by a property in the SmartObject
· A single row in the SmartObject represents an instance of the process being executed
· All property values for the row being executed needs to be ‘0’, indicating that there are no activities being processed
![clip_image008[4] clip_image008[4]](http://k2underground.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/pitchblack.metablogapi/7725.clip_5F00_image0084_5F00_thumb_5F00_3C747FA8.jpg)
K2 Process Design
· The process design at first glance may appear clunky but is not. This process design caters for all of the destination types with regards to slots: ‘Plan just once’, ‘Create 1 slot’ and ‘Create a slot for each destination’
![clip_image010[4] clip_image010[4]](http://k2underground.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/pitchblack.metablogapi/2626.clip_5F00_image0104_5F00_thumb_5F00_6E1F7730.jpg)
How it works: [Create Status Instance]
![clip_image012[4] clip_image012[4]](http://k2underground.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/pitchblack.metablogapi/5756.clip_5F00_image0124_5F00_thumb_5F00_1953E86B.jpg)
· This activity is the activity that creates a single record in the SmartObject.
· For each activity the initial status is set to ‘0’. This is required since some activities may not be executed and will as a result not be able to set a completed (‘0’) status flag.
· The ‘itemId’ returned will be used to update all subsequent calls to the DB
· Once this activity finished processing the ‘Preceding Rule’ Smartobject record will look like this:
activityONEstatus activityTWOstatus activityTHREEstatus activityFOURstatus
0 0 0 0
How it works: [I am busy ...]
![clip_image014[4] clip_image014[4]](http://k2underground.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/pitchblack.metablogapi/2526.clip_5F00_image0144_5F00_thumb_5F00_4FE193AF.jpg)
· These steps indicate per activity whether or not a specific activity received scope to be executed
· Each activity invokes the ‘Preceding Rule’ Smartobject and sets the value for the related column to ‘1’, this indicates that the activity is ‘busy’
· Why the extra activity?
Performance – in most cases, the activity behaviour with regards to destinations creates a single slot with multiple destinations and ‘Plan-just-once’ is not enabled. If we were to add this event in the event with multiple destinations, a number of unnecessary updates will be executed against the smartobject – one for each destination.
How it works: [I am done ...]
![clip_image016[4] clip_image016[4]](http://k2underground.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/pitchblack.metablogapi/1121.clip_5F00_image0164_5F00_thumb_5F00_429B0A9C.jpg)
· Once an activity (ONE, TWO, THREE or FOUR) has completed, it has to indicate that by setting the related column value in the ‘Preceding Rule’ SmartObject to’0’.
· Why the extra activity?
Performance – same applies as per [I am busy ...]
Incorrect status value – if the event in this activity was added to the activity (ONE, TWO, THREE or FOUR) with multiple destinations multiple slots, the first person to complete his/her work would update the item status to complete, then when the ‘Continue Processing’ activity preceding rule executes it would evaluate to ‘true’ where in fact it should be false.
How it works: [Continue processing]
![clip_image018[4] clip_image018[4]](http://k2underground.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/pitchblack.metablogapi/5756.clip_5F00_image0184_5F00_thumb_5F00_39CB0250.jpg)
· For each line connected to this activity, the preceding rule will evaluate all column values for this instance. Since we already set the columns values for activities to ‘complete’ even though those activities never got scope, stock standard K2 blackpearl functionality could be used to resolve the preceding rule.
· The configured preceding rule:
![clip_image020[4] clip_image020[4]](http://k2underground.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/pitchblack.metablogapi/7206.clip_5F00_image0204_5F00_thumb_5F00_5DA3B3DD.jpg)
Sample illustrated
[Create Status Instance] - PrecedingRule SmartObject data
activityONEstatus activityTWOstatus activityTHREEstatus activityFOURstatus
0 0 0 0
![clip_image022[5] clip_image022[5]](http://k2underground.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/pitchblack.metablogapi/0363.clip_5F00_image0225_5F00_thumb_5F00_538F12B2.gif)
[I am busy ...]
PrecedingRule SmartObject data each activity sets the relevant SmartObject property
activityONEstatus activityTWOstatus activityTHREEstatus activityFOURstatus
1 0 1 0
![clip_image024[4] clip_image024[4]](http://k2underground.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/pitchblack.metablogapi/1033.clip_5F00_image0244_5F00_thumb_5F00_29CB97BF.gif)
[I am done ...]
· For each of the activities ONE... to FOUR, once they finish execution they set their underlying execution status to 0
· When THREE finishes before ONE the status table will look like this:
activityONEstatus activityTWOstatus activityTHREEstatus activityFOURstatus
1 0 0 0
![clip_image026[4] clip_image026[4]](http://k2underground.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/pitchblack.metablogapi/1856.clip_5F00_image0264_5F00_thumb_5F00_2DF56F84.gif)
[Continue processing]
Only when ONE finishes does the preceding rule in ‘Continue Processing evaluate to true
activityONEstatus activityTWOstatus activityTHREEstatus activityFOURstatus
1 0 0 0
![clip_image028[4] clip_image028[4]](http://k2underground.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/pitchblack.metablogapi/5241.clip_5F00_image0284_5F00_thumb_5F00_6416E7D3.gif)

Posted
Tue, Nov 24 2009 12:10 PM
by
Willem