Workflow Wishlist #2 – onDelegateEvent

5 10 2010

The second item on my wishlist for Dynamics AX workflow is to have an “onDelegateEventHandler” option available for tasks and approvals. I must admit that this would most probably not be a very widely used function within AX workflow, but here is why I would like to have one.

Given the way that workflow manages the assignment of workitems, there is no way of determining when and to whom tasks are assigned to people, in order to perform some type of custom action like updating an external system or table. Even making use of custom ParticipantProviders, one does not have a guarantee that it will end up at the person that your provider class is returning, due to delegation settings.

Thus an onDelegate event handler would be very useful. Unfortunately workflow does not have any eventhandlers for individual workitems, rather just set on tasks, so this may be difficult to accomplish.

My workaround:
It is relatively easy to tap into the WorkflowTrackingTable’s (Table) saveTracking Method and kick off some custom action using the record ‘trackingTable’. The trackingTable record contains a useful field  called TrackingType (enum WorkflowTrackingType) which can provide you with more informations as to what has just occurred. E.g. WorkflowTrackingType::Delegate, WorkflowTrackingType::EscalationPath, WorkflowTrackingType::Creation. Using this you can then perform whatever action you would like to do e.g.

if (trackingTable.TrackingContext == WorkflowTrackingContext::WorkItem)
  if (trackingTable.TrackingType == WorkflowTrackingType::Creation)
        doAction(trackingTable.User); //this is the user to whom the workitem has finally been assigned 
  else if ((trackinTable.TrackingType == WorkflowTrackingType::Delegation) || (trackingTable.TrackingType == WorkflowTrackingType::EscalationPath))
       doAction(trackingTable.ToUser); //to whom the workitem is now assigned (delegated/escalated)
N.B. Be warned, you are modifying system classes so be careful when you are installing new hotfixes or upgrading.
Happy Daxing
Comments Suggestions?



One response

8 07 2011

Hi – New to AX (aren’t we all lol), I am configuring a Workflow with conditional statements – my problem is I can not find any comments on what syntax / parameters i can use on the UI side.

for example I want a subworkflow to activate when the division = 1, 2, 4, 6, A. Currently I have to use a line for each and use “And”. In sql i could simply list the values – can this be done in the UI out of the box – and if it can what do i use to separate the values – I tried commas etc – nothing works – it might just be you cant do lists etc – but seriously it would be a basic feature to support lists and ranges or so I think.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: