CRM 2011 - Two workflows running at the same time, can one update a field and the other access it? RRS feed

  • Question

  • I am pretty new to CRM 2011 and I have been working through things just this week and last week.  So I have about 8-days under my belt.  I am running into something that seems like there should be a built-in way to handle it, or maybe I am just missing something rather simple. 

    What I have is a workflow that someone else created.  It is triggered when a given field is updated on a given entity.  So there's a field that is updated, and that fires the WF.  The end result of the WF is that am email is sent to our customers, as they are new customers and we send a sort of welcome email.  When the WF is compeleted we update a email status field to 1-true so that any future triggers that execute the WF will not send the email.  Pretty simple and strait forward really.  Getting CRM to do this, that is the problem.

    The problem is that a legacy system is integrated here and the legacy system actually triggers the WF multiple times... and at virutally the same time.  So we have WF-1 and WF-2 running at the same time.  So when we check that email status in WF-1 and update it to true, WF-2 doesn't know about.  It seems that when the WF starts up it reads the database and holds the values in memory.  Is there a way to tell it to go back and read the current status before the email is sent, just to make sure WF-1 did not update it since WF-2 started?  Or better yet, is there a way to have a WF do a sort of queue process so that these two WF cannot run at the same time?  That seems like the best option.

    The only way I can see to get around this, unless there is so mechanism in CRM to handle this, is to build a second workflow to trigger off the email status.  I suspect that the second WF would then read from the database before it runs.  But I might have the same issue again if both WF are running at the same time.

    How do you handle this sort of thing in CRM?  It seems like a rather common need.

    Best regards,

    Jon Rothlander

    Jon Gregory Rothlander

    Thursday, January 30, 2014 9:31 PM


  • Hi,

    To prevent this issue you could have two kind of solutions:

    1- Use the second workflow as a child workflow. First, check the second workflow (run as child workflow), then in the first workflow call it. You should update the fields first, then run the child.

    2- Use a "wait condition" in the second workflow. For example you could wait 1 minute, then check the email sent field (it was updated before this) and then rest of the workflow.

    Iranian Dynamics CRM Association | انجمن متخصصان ایرانی

    Friday, January 31, 2014 8:55 AM