Triggering Flows With A Dynamics Field Change (And Calling A Flow From A Workflow)

Standard

There were many excellent sessions at Dynamics UG EMEA (CRMUG EMEA) in Dublin and, as I recently mentioned in my Tip of the Day, if there is a Dynamics Saturday or Dynamics UG event near you, they are an excellent investment of your time (and not necessarily a large investment in cash).

One question that came up during one of the sessions was how to trigger a Flow on the change of a field. One suggestion was ‘WebHooks’. Talking to the developers in my team they agreed this could work but it struck them as a fair amount of effort for just triggering a Flow. So I wondered if we could put something together with configuration.

Here is the idea I came up with.

What Can We Do Without Thinking Too Hard?

For those that have not tinkered too much with Flows, the Dynamics triggers available are all at the record level. We have:

  • OnCreate (when a record of a specific entity is created)
  • OnDelete (when a record of a specific entity is deleted)
  • OnUpdate (when a record of a specific entity is updated)

Clearly, if I am waiting for a field to change, I have the OnUpdate but this triggers on ANY field change which is inelegant but also potentially expensive when we pay for Flow by the triggering.

My Solution

Back in my Workflow Scheduler blog article, The Flow created a record in Dynamics which triggered the Workflow. This time, we are reversing that. The order of events is:

  1. A field is changed on a record (say the Est. Close Date of an Opportunity)
  2. A workflow is triggered to create a custom entity child record
  3. Flow monitors for the OnCreate of such records and then fires.

There it is. That simple. So what does it look like?

The Custom Entity

image

The custom entity has a name (which we could use as a variable for triggering different Flows) and a link back to the original record where the field change happened.

The Workflow

image

In this case, the Workflow triggers off of the change of the Est. Close Date. and creates a Flow Field Trigger record.

image

We could also use the Workflow to pass values from the Opportunity down to the Flow Field Trigger for posterity but for the purposes of the blog I will keep things simple.

The Flow

image

I have only created the trigger here as the steps could be anything you like. With the lookup to the originating Opportunity, we have access to all information as if we triggered the Flow directly. As mentioned, we can also bring values from the Opportunity down to the Flow Field Trigger record, with our Workflow, to simplify things.

Bonus Result: How To Trigger A Flow From A Workflow

The more astute of you (and those that read the title) will realise we also now have a method for triggering a Flow from a Workflow (no, v9 does not have a Workflow Step for this). Just as we triggered a scheduled Workflow by creating a record via Flow previously, here we are triggering a Flow by creating a record via a Workflow.

Conclusions

For entities where record creation or update rates are high, triggering a Flow off of the record creation/update may be problematic. While this option requires a little configuration, it gets around this problem and, as with the scheduled Workflow solution, also provides a record to track related Flow actions within Dynamics (with the option of storing the values at execution as well).

3 thoughts on “Triggering Flows With A Dynamics Field Change (And Calling A Flow From A Workflow)

  1. Say, for instance, a Flow is refreshing the entity and denoting the whole record as refreshed.

    In this way, it might be helpful to distinguish which fields are being utilized to trigger work processes. You could comprehensively open up each work process and check or you could tap on each field in each element and Check Dependencies, however gratefully, there is a less demanding way.

    Like

Leave a Reply

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

WordPress.com Logo

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

Facebook photo

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

Connecting to %s