Search code examples
dynamics-crm

One workflow or multiple workflows?


I have an opportunity form and it has 4 statuses on it. For each of those statuses, I want to have a status date on it.

When I'm making my workflow, I know that I can simply create four workflows to get the effect I'm looking for, but can it be done all in one workflow?

So if status 1 and 2 are changed, the record is saved, I'd want status 1 date adn status 2 date to update to today's date, but not status 3 date or status 4 date.

I have a feeling the answer is no, but thought I'd check


Solution

  • Correct. In a workflow, if you are triggering the workflow by multiple fields on an Update message, you only know that at least one of those fields was changed, so you would have to use 4 workflows to accomplish your goal.

    If you are worried about having too many workflows, you could use a plugin to accomplish this. As an example, you could do something like this:

    Entity entity = (Entity)context.InputParameters["Target"];
    if(entity.Attributes.Contains("new_status1"))
    {
        entity["new_status1date"] = DateTime.UtcNow;
    }