Retrieve Records in N:N relationships with FetchXML and the New CDS Connector in Microsoft Flow

Have you tried to retrieve a list of records in Flow and had to go trough a many to many relationship condition? If you have I can relate to the frustration and complication that task brought. Earlier this week I found a solution – and it was easy, really easy. Let me show you what I found.

What’s so new with this CDS Connector?

So let’s start with talking about the “new” CDS Connector. I say new but really it was released this June, I just haven’t payed attention to it’s awesomeness until now. This CDS Connector is only available when you create your flow from a solution.

It only has one trigger – but it’s pretty darn good. It reminds us CRM-folks about the classic Workflow designer when it comes to trigger conditions. It’s also no need to define what environment you want your flow to trigger from. Since it’s created from a solution, it will run from the environment the solution is deployed to.

The connector also offers a lot of actions, many of them you probably recognize from the other CDS Connector. But the List Records action has one HUGE difference compared to it’s sister – Fetch XML Query.

List records in a N:N relationship

Let’s use a classic example – a contact can speak several languages. I create a N:N relationship to a custom entity called Language and now I want to list all Contacts that speak Swedish in my Flow.

The absolute simplest way is to do that exact search in Advanced Find and download the Fetch XML.

In the action just choose what Entity you want to list, and then copy and paste the whole thing into the Fetch Xml Query field.

Insanely simple right? No more sleepless nights and nested List Records-actions with the old CDS connector. This simplifies it tremendously.

A Bug that Complicates Things

Using the actions and trigger from this Connector does not only bring good things unfortunately. Populate lookups in the actions “Update a Record” or “Create a new Record” doesn’t work with only dynamic content. I found the solution to the problem here. Workaround suggested in that forum is for example to populate Account lookup like this:

Flow away!

Kontakta oss med dina frågor!

Känner du dig osäker eller är du redo att komma igång? Kontakta oss så svarar vi på alla frågor eller föreslår ett uppstartsmöte där vi går igenom era behov.