0
votes

I have a workflow that runs when an entity is created and it creates two other entities and puts them on a queue. It then waits until each entity's status reason is set to done. After which is continues.

Basically two teams will work an order and then it will continue processing after both teams are done.

Most of the time it works. However sometimes it waits forever. I'll re-active and re-resolve the other tasks, but it just never wakes up.

What can I do? The workflows aren't really powerful enough for me to have it poll with a timeout (there are no loops). I'd like to avoid on-change plugins for these other entities to get workflow behavior all scattered about.

Edit: Restarting the CRM services (not sure which did it, I restarted them all) allowed the workflow to resume. However, I'd still like to know how to make this more reliable.

1
Is an error being thrown in the progress window? If a recoverable error is thrown the workflow will remaining in waiting status but can then be resumed. The Crm Asynchronous Service is the one that manages workflows.Zach Mast
@Zach There wasn't an error the progress window when viewing the workflow. It just showed that it was waiting on the wait step.LameCoder
What is the relationship between the entities and why can you not have an "on status change" workflow on the two entities that are created from the first entity?Ollie
They're both different tasks related to doing an install for a customer. One is administrative, the other technical. Both have to be done before sales moves forward with other things. On Status Change would work, but it'd be splitting up what is basically one workflow into several places, and would be harder to maintain.LameCoder

1 Answers

0
votes

I had the same problem (and a lot more) with workflows in CRM 2011 and decided not to use them (except for very special purposes). The main reason is because of their very limited error handling. Another reason is that it is inconvenient to put them under source control. Another reasons are: Worflows cannot run offline and user impersonation is also not supported. For a comparison look here: http://goo.gl/9ht1QJ

Use plugins instead of workflows, then you have full control.

But keep in mind that plugins (unlike workflows) are not designed for long running tasks. So they have a default max execution time of 120 sec and are not stateful/persisted. But in most cases (and i think also in your case) that is not a problem. Just change your eventing a little bit:

  • Implement and register a plugin step for: entity is created and it creates two other entities and puts them on a queue
  • Implement and register another step: entity's status reason is set to done, query for other entity and check status, if done continue processing

If you really do not want use plugins for you business logic you can consider implementing a plugin which restarts/resumes faulted workflows. But thats not a very nice solution.