Tip #1397: Reduce extra Power Automate runs and overcome trigger limitations

You know I’m a sucker for some open source goodness. This time the goodness is from Aiden “President” Kaskela. (Got something to share? Send your wares to jar@crmtipoftheday.com).

The Common Data Service (Current Environment) trigger in Power Apps allows you to run your cloud flow when certain fields are updated, but there are two shortcomings:

  1. Your flow can trigger on multiple fields and you don’t know which one changed.
  2. In the Dataverse, fields may register as a change even if the value doesn’t (typically caused by updates through code where it’s including the current field value instead of just the changes).

Since you don’t know what fields changed, or if they’ve even changed at all, your flows may be running unnecessarily and doing a lot more work than they need to – and in a world with API limits, that’s something to be concerned about.

I build Power Automate Assistant to address these challenges, which not only tell you what fields changed but also cut down on the number of flow runs due to ghost updates. This tool is open source and available through the MIT license.

The Dataverse considers a field as having changed even if the value doesn’t actually change. We can’t control that. What we can do though, is create a new field and control when and how that is changed. By ensuring only true changes are tracked, we can bypass unnecessary flow triggers.

Here’s how it works:

In this example, we have a flow that runs when a Contact is created or updated, if the First Name or Email changes.

  1. Create a new text field on your entity (afk_ModifiedFields). In this case I’ll stick with 100 characters, but it should be as long as all the schema names for the fields you’re tracking.
  2. Install the Power Automate Assistant and configure it on the contact so it runs any time the First Name and Email changes.
  3. When those fields are updated, the tool will evaluate the field values to ensure it actually changed. If the fields have changed, it’ll update the new text field (afk_ModifiedFields) with the field names that changed.
  4. Configure your flow to run on afk_ModifiedFields.

What happens now?

With this setup, if you update the contact’s email address and save the record, your new text field will say “emailaddress1”. If the first name changed, it’ll say “firstname”. If both changed, it’ll say “emailaddress1,firstname”.

By setting your flow to run on that text field, we can ensure it only triggers if we have a real change, and on top of that, you can treat that new text field as an array and see what fields triggered the update and take actions accordingly.

Enjoy!

Where do I get it?

Managed and unmanaged solutions and source code is available at https://github.com/akaskela/PowerAutomateAssistant

Step-by-step instructions in the wiki on Github https://github.com/akaskela/PowerAutomateAssistant/wiki/TrueFieldChange

Cover photo by Photoholgic on Unsplash

Leave a Reply

Your email address will not be published. Required fields are marked *