web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Forcing Multiple Workflows to Process in Sequence

(0) ShareShare
ReportReport
Posted on by 720

I'm hoping someone may have an idea for this issue.  

I have a workflow that calls a DistributeOneToMany Child Workflow create Projects and the copy data from an Opportunity to the created Project.  However, they need to update a temporary lookup field (to allow copying of some other Opportunity child entity values to the correct project) and finish processing before the next one can do the same.  

My problem is that all the child workflows created by the DistributeOneToMany tool execute at the same time. They all write to the temporary lookup field, even when I use "Wait Until" with a processing flag field.   So basically all the child values that should be copied are dumped into one project, when they should be split amongst the number of projects (anywhere from one to five projects get created).

If I can introduce a slightly different processing time to each generated child workflow, my logic seems to work fine.  However, when they are triggered normally, it seems like they all plow right through the "Wait Until" field because they all try to lock it at the same time.

Any ideas on how to do a randomized wait at the start of a workflow (say between 0-60 seconds)?  Or does anyone have another idea on how I can force the workflows to wait while each processes?

Thank you in advance!

*This post is locked for comments

I have the same question (0)
  • Verified answer
    Marius Agur Pedersen Profile Picture
    1,771 on at

    This is not posible for out-of-the-box workflows. Asynchronous workflows are added to a table in the CRM-database before they are picked up by the asynchronous processing service. The async service picks up up to several thousand operations at once (each step in a workflow is one operation). There is no way to tell the async service which sequence they should execute in, it just takes a bunch and "gets the work done".

  • BJMcmullan Profile Picture
    720 on at

    Marius -

    Thank you for the comments.  While they all execute in the async service, I don't understand how they all get past my "Wait Until" Processing Flag is set.  Occasionally, it seems to work, but most times it seems like they get to update the same record at the exact same millisecond and skip right past the processing flag.

    Is there way to introduce a randomized wait at the beginning of a workflow?  If I set a static one, I'm sure they will all wait the exact same amount of time and the issue will continue.

    Thanks for the thoughts!

  • Suggested answer
    Marius Agur Pedersen Profile Picture
    1,771 on at

    Are they executing before the "wait until" expires? If not then the answer is that "wait until" actually is "wait until atleast", because the async service gets a bunch at the same time, and it gets the oldest ones first, it will start processing all the workflows where "wait until" has passed at the same time.

    The async process gets new operations to execute every few minutes by default, so if you want to set "wait until" on all of your child processes then you'd have to specify atleast 10-15 minutes between each of them for this kind of processing to work. Either way, if the async process is stopped (if it crashes for example), then all of your "wait until" timers will have expired by the time it is back up, and then it will get x number of operations based on the oldest createdon-date. Please note that the createdon does not guarantee which operation is executed first, it just defines which x operations are picked up at the same time.

    Please let me know if the explanation wasn't clear enough.

  • Verified answer
    BJMcmullan Profile Picture
    720 on at

    Marius,

    Thanks additional details.  I wasn't aware that is how the async engine worked.  With your input I was able to determine while I could get it to work occasionally, it wasn't as consistent as would be required.  Really appreciate your help

    To anyone else who may find this post:

    To fully resolve the issue, I switch to Real-Time workflows on all workflows associated with the process (1 Parent Workflow with 3 Child Workflows).  This seems to force everything to run sequentially, which is exactly what was needed.  This allowed my original design to work allowed me to remove all Waits and Locking fields.  I guess the logic should be when you need things to run in a specific order, use Real-Time Workflows,.

  • Peter Bohn Profile Picture
    on at

    Hi everyone,

    I read you posts with great interest, cause i have a such huge amount of workflows running at the same time and triggering on same and/or different field changes.. That there were some really ugly errors, if there were changes to field values of a huge amount of records.

    I read about time limits, execution errors and stuff like that.

    I thought of getting many more errors if a switch from async to sync???!!!

    why do you think, chancing to async could reduce the errors...

    do you surely know, that making a starter workflow, where i define the order of the executing sub workflows will be right if i use sync and if using async the execution order will be not right and they change to parallel execution?

    hopefully you could help me too... I try to explain

    I have a async starter wf which trigger fe. on field change

    in this i decide the order of sub workflows

    I do this because of the gotten errors.. Cause they were the result of trying to write things, but another wf tried to write things too.

    if i had this all in sync there came errors because the execution time was to long.

    Maybe one of the problems were, that there were 1500 records update (with webservice) in the same field, which triggered the starter wf

    and I this starter wf there were other fields changed, which started another starter wf for this other field. And so on.

    But are 1500 records really to much for crm??

    Ok there were much follower field updates, but how else could i do this?

    Thx.

    Greets PeB

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

News and Announcements

Season of Giving Solutions is Here!

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans