Creating a Flow to add a Many-to-Many Relationship

   Words by Paul McQuillan

   on 28/04/2020 08:00:00

When reviewing one of our Dynamics Prototyping Projects, we identified a Requirement where we wanted a new Many-to-Many (N:N) link to be created immediately as a new Quote was recorded.

Typically creating a new Many-to-Many link could be difficult in traditional Dynamics Workflow, and so thought this would be a good worked example for how we can use Power Automate (nee Flow) to implement this requirement.

So, getting started, we kick off by adding a New Flow to our Dynamics 365 Solution and defining a Trigger for the Common Data Service (current environment) for when a record is created, updated or deleted.


In my case, I am looking to trigger when a new Quote is created in CRM.

From there, I want a List Records Action to define what other records that I am seeking to associate to my Quote – in my case, a Custom Entity titled ‘Other Costs’.

We don’t want all the Other Cost records, only a subset tagged as ‘automatically create with Quote’ – so I can jump into a Dynamics Advanced Find and produce a block of Fetch XML that returns me the right set, and then feed this Fetch XML into the List Records step.


With my Flow’s input established, I can then add the action I want to run as the Flow’s Business Logic / Output – in this case, looping through each of the returned records and adding the association that would link the New Quote to the returned Other Cost record.

This is where we need to use the Relate Records Action and it does have a bit of quirkiness to overcome.


Afterwhich we supply the ID of our Other Costs record, select the N:N Relationship we want to associate and then come to which Quote we want to associate to.

Here we need to supply a piece of syntax that points Flow to the Entity’s reference in the Dynamics REST API, this delves into mild development territory and so is a bit weird, but we can map this out:<entity-db-name>(ID)

So for my notation:


This then specifies the Quote to link to the Other Costs record.

With this built, my Flow is done and so its onto Testing.

To start with, I need to manually trigger the Event in Dynamics that will start my Flow – in my case, creating a new Quote:


I then dive back into Flow to see how the execution went from this manual trigger:


This then helps define my new Quote:


And so we have a new piece of logic to automatically add 1 or more associations for each Quote we add to Dynamics 365.

Historically this would require a quick Custom Workflow Activity or a Post-Update Plugin, but here we can realise the same requirement with a Low Code approach.

More Reading on Power Automate

This is a great article for help when using the Relate Records Action -

CRMCS Post to help with the List Records Action - 

Microsoft Documentation on the Common Data Service (current environment) -

Share this Article

Search Articles

Filter Articles

CRM Tech DocMan

Recent Articles

HOW TO: Virtual Entities in Dynamics 365 Release Wave 2 New Feature: The Columns Button HOW TO: Search a date field in Microsoft Dynamics The Relevance Search COMING SOON to Power Apps Portals HOW TO: Manage Your Dynamics 365 Database Size (Video Included) Dynamics 365 Marketing vs ClickDimensions It’s time to pause, reflect and acknowledge a new era of inclusivity and collaboration. Part 2 - How to get the most from a Technology Expert – Asset Management Hub Property & Asset Management Hub Part 1 – Balancing CRM and Asset Management Scopes - Asset Management Hub Creating a Multi-Lingual PowerApps Portal How to Set Up a Microsoft Teams Site Using DocDrive365 Microsoft Teams - Adding a Microsoft Teams URL to a Dynamics Appointment Dynamics 365 Marketing – Customer Voice Survey Not Appearing In Emails? Using SQL Management Studio to connect to the Dynamics DB Calling a Power Platform AI Builder Model via oData How to use DocDrive365 to integrate permissions between Business Units in Dynamics with Sites in SharePoint Getting started with the Power Platform AI Builder. Power Apps Portal Information Hub DocDrive365 Security: Day One - Getting Started with Dynamics to SharePoint Permissions Part 5 - Power Apps Portals: How To Connect Azure B2C With Linked-In Part 4 – Power Apps Portals: Styling Azure B2C for Power Apps Portals The 3 Phases for Using Multi-Select Option Sets in Flow with Microsoft Forms Part 3 – PowerApps Portals: Azure B2C and Power Apps Portals – User Flow for Signup and Signin Part 2 - Power Apps Portals: New Application Registration in Azure B2C for our Power Apps Portal
Contact Us

Want expert advice or a demo?

Get in touch now and see how we can help your business grow.

  • Name
  • Email Address
  • Phone Number

Understanding Your Challenges

Our strong understanding of CRM and emerging technologies within the Microsoft environment means we deliver the right solutions for you.

Proven Real-World Solutions

As a leader in the field of Dynamics solutions, our pedigree developing and delivering real-world solutions is unsurpassed.

Long Term Support

We provide support beyond our design, implementation and 'go-live' delivery using Sprints and continual updates to our AppSource apps.

CRMCS | Design by Thinktank Marketing | Citrus-Lime Limited

To improve your experience today and in the future, this site uses cookies. Read our full Privacy Policy & Cookie information here I Understand