PowerAutomate, Dataverse and FetchXML: Advanced Filtering Made Easy

Ok a bit of a long title for this post but I genuinely couldn’t think of anything better, sometimes many words are needed! Here we go.

When using PowerAutomate and specifically the List Rows Dataverse action to find specific records, using FetchXML instead of (or in addition to!) an OData query in the Filter rows section can sometimes come in handy if you are looking to filter rows based on related tables. Let me explain :p

Imagine that you want to get all Account records in Dataverse that have active Contact records but specifically active Contact records that have an address in London, UK. This can be quite complex to create just using Filter rows and OData but there is an easy way to get what you need using FetchXML – and here is the good part: you don’t need to know anything about FetchXML to do it! You can use the familiar Advanced Find, yay! Here’s how it works…

In the Dataverse List Rows action there is an option to add a Fetch Xml query:

All you need to do is get the FetchXML and paste it in there, here’s how you get it. Firstly, select the Advanced Find icon and select the table you need to list rows for (in this example it would be the Accounts table):

You will then be presented with the Advanced Find filtering – add the filtering as required and then click on Download FetchXML:

A file will download with the FetchXML included in it – open the file and copy the whole FetchXML text:

Back in your cloud flow, paste it in the Fetch Xml query box, should look a bit like this:

That’s it! Your List Rows action will now give you only the accounts meeting the criteria you selected in the Advanced Find. Cool huh?

Happy PowerAutomate Dataverse Filtering 😀

The Power Automate and Dataverse Cheat Sheet

Back in June I presented at the UK Dynamics 365 and Power Platform User Group event in London (yey!) – the next one is in November, do join!

One of my sessions was a ‘101’ Intro to Power Automate and Dataverse. I wasn’t sure how many people would attend this session given that this isn’t a new shiny topic but I could imagine that outside the world of consultants, MVPs, techy wizards and general overachievers there were people with no background on this thing, just trying to make sense of how to use it and create flows, struggling to get past the errors and warnings and failures. We’ve all been there…

Thankfully many people turned up and asked a lot of follow up questions (yey!) and in the general speaker Q&A afterwards one of them raised a valid point – there is no one place that someone can go to and get a cheat sheet for the tiny little nuances of Power Automate – the things you only figure out through excessive online searching or through someone else who has ‘been there/done that’ and shows you the ropes. I figured I could at least have a stab at that and build on it over time with help and suggestions from you dear readers, so I promised I would do it.

So here you are – a Power Automate and Dataverse Cheat Sheet – lets be honest, sheets – version 1! Enjoy, and give me feedback – lets make this awesome!

PS: See here for some advanced filtering info you might find useful if that’s your thing!

Cracking the JSON of Cloud Flows

Recently I had to do an analysis of a lookup field’s dependencies because it needed to be replaced by a new field looking up to a different table (itself a long story…).

It was all going well, I went into the Maker Portal, I found the table, found the field (sorry – column!), selected it and clicked ‘Show Dependencies’. Wonderful!

Except…

The dependencies list will only show you the cloud flows that use this field column as a trigger – not as a condition or action or anything else outside of the trigger. Which means that you are able to delete the field even if it means a bunch of flow actions will suddenly start failing because the thing doesn’t exist anymore. Where’s the fun in that….nowhere I tell you!

Soooo…what does this mean?

WELL. It basically means you have to search all cloud flows and see if any actions are using that field. Yep. I know. Thankfully there is an automated way to do this – don’t be that person that spends 2 weeks looking through flow actions #aintnobodygottimeforthat. Let JSON Crack do all the work for you! To learn more about JSON Crack in general and other ways to use it click here.

Using JSON Crack

It is super easy. First you need to get JSON from your environment of choice giving you all the (active, if you so wish) cloud flows in the system. You can do this by sticking the below in your browser – don’t forget to update it for your actual environment:

https://environmentname/api/data/v9.0/workflows?$select=clientdata,name&$filter=(category%20eq%205%20and%20statecode%20eq%201)

It will look like this – copy all the text. Ctrl + A, Ctrl + C is your friend.

Get Cracking

In a new tab (or the same tab, whatever makes you happy), go to https://jsoncrack.com/editor and on the left pane, delete what is there and paste the JSON from the API:

You will then see a wonderful long list of all the cloud flows on the right:

Here’s the good bit – you can use the Search Node box on the top right to look for the schema name of your field – this will search the JSON for any mention of this field in any of the flows which will get a green outline and you can press Enter to move to the next flow that mentions it:

You can also click on a flow to copy the details of it (e.g. name, id) and then open that flow in the Maker portal to see exactly where your field is used and make the necessary changes.

You can then repeat this process to ensure no more mentions of the field exist and then delete it.

Yey for JSON! This is a great tool for visualising JSON data in general so keep it in mind! Big thanks to Christy O’Kane for making me aware of this awesomeness!

Alternatively…

Top Tip by Cris Fernandez:

If you use Chrome, you can view and search this JSON within the browser tab by installing the JSON Formatter extension by Callum Locke. It will format the JSON for you (it will still be a wall of text but a structured wall of text!) and you can then use the browser search (Ctrl + F) to find the field schema. It will be quicker, show you all the places the field pops up, and exactly what has been found as a match in the JSON:

Woop Woop!