{"id":22910,"date":"2020-02-24T11:28:07","date_gmt":"2020-02-24T11:28:07","guid":{"rendered":"https:\/\/www.inogic.com\/blog\/?p=22910"},"modified":"2022-07-19T16:25:18","modified_gmt":"2022-07-19T10:55:18","slug":"associate-disassociate-two-entities-with-1-n-and-n-n-relationship-using-relate-unrelate-records-in-power-automate","status":"publish","type":"post","link":"https:\/\/www.inogic.com\/blog\/2020\/02\/associate-disassociate-two-entities-with-1-n-and-n-n-relationship-using-relate-unrelate-records-in-power-automate\/","title":{"rendered":"Associate \/ Disassociate two entities with 1: N and N: N relationship using Relate &#038; Unrelate records in Power Automate"},"content":{"rendered":"<h2>Introduction<\/h2>\n<p style=\"text-align: justify;\">Power Automate has been introducing new features and one of them is \u2018Relate\/Unrelate Records\u2019 feature. This is a step towards new common data service connector and it supports 1: N, N: N relationships. Now, let\u2019s see with an example how it works. We have two entities \u2018Contact\u2019 and \u2018Web Role\u2019 and there is N: N relationship between them.<br \/>\nOur flow will run on the creation of contact and for that contact we will set default web role as authenticated users.<br \/>\nHere, we first initialize a variable and set the default role name in it.<\/p>\n<p><img decoding=\"async\" class=\"aligncenter size-full wp-image-22911\" src=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2020\/02\/1Associate-and-disassociate-two-entities.png\" alt=\"Associate and disassociate two entities\" width=\"624\" height=\"431\" srcset=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2020\/02\/1Associate-and-disassociate-two-entities.png 624w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2020\/02\/1Associate-and-disassociate-two-entities-300x207.png 300w\" sizes=\"(max-width: 624px) 100vw, 624px\" \/><\/p>\n<p>Now, fetch the web role using the web role name.<\/p>\n<p><img decoding=\"async\" class=\"aligncenter size-full wp-image-22912\" src=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2020\/02\/2Associate-and-disassociate-two-entities.png\" alt=\"Associate and disassociate two entities\" width=\"496\" height=\"540\" srcset=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2020\/02\/2Associate-and-disassociate-two-entities.png 496w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2020\/02\/2Associate-and-disassociate-two-entities-276x300.png 276w\" sizes=\"(max-width: 496px) 100vw, 496px\" \/><\/p>\n<p>We also need to initialize one more variable to store the @odata.id of the web role which is actually a full resource URL of web role e.g. <a href=\"https:\/\/organizationName.crm8.dynamics.com\/api\/data\/v9.0\/adx_webroles(844598bc-d0cb-410a-b2de-b6f2c4dbc487)\">https:\/\/organizationName.crm8.dynamics.com\/api\/data\/v9.0\/adx_webroles(844598bc-d0cb-410a-b2de-b6f2c4dbc487)<\/a><\/p>\n<p>(CDS connector dynamically provides it along with the record details.)<\/p>\n<p><img decoding=\"async\" class=\"aligncenter size-full wp-image-22913\" src=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2020\/02\/3Associate-and-disassociate-two-entities.png\" alt=\"Associate and disassociate two entities\" width=\"618\" height=\"186\" srcset=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2020\/02\/3Associate-and-disassociate-two-entities.png 618w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2020\/02\/3Associate-and-disassociate-two-entities-300x90.png 300w\" sizes=\"(max-width: 618px) 100vw, 618px\" \/><\/p>\n<p>In the next step set the value of our role id variable.<\/p>\n<p><img decoding=\"async\" class=\"aligncenter size-full wp-image-22914\" src=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2020\/02\/4Associate-and-disassociate-two-entities.png\" alt=\"Associate and disassociate two entities\" width=\"655\" height=\"384\" srcset=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2020\/02\/4Associate-and-disassociate-two-entities.png 655w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2020\/02\/4Associate-and-disassociate-two-entities-300x176.png 300w\" sizes=\"(max-width: 655px) 100vw, 655px\" \/><\/p>\n<p>Here, you will see we are setting up only one web role in the contact record and that is the reason we are using the variable to initialize and set it by the web role id in the apply to each loop, but we could have the requirement to set more than one web role in the contact so at that time we must place the related records step inside the apply to each loop instead of setting up variable.<\/p>\n<p>Now at last set the Relate Records step where one needs to set some properties as listed below.<\/p>\n<p>The properties you are required to fill are as follows:<\/p>\n<ul>\n<li>Entity Name: &#8211; Select the entity that has N: N, 1: N relationship with associate entity, in our case the contact.<\/li>\n<li>Item Id: &#8211; Record id.<\/li>\n<li>Relationship: &#8211; Select the relationship.<\/li>\n<li>URL:- Full address of the associated entity record, which we have stored in the role id variable.<\/li>\n<\/ul>\n<p><img decoding=\"async\" class=\"aligncenter size-full wp-image-22915\" src=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2020\/02\/5Associate-and-disassociate-two-entities.png\" alt=\"Associate and disassociate two entities\" width=\"618\" height=\"220\" srcset=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2020\/02\/5Associate-and-disassociate-two-entities.png 618w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2020\/02\/5Associate-and-disassociate-two-entities-300x107.png 300w\" sizes=\"(max-width: 618px) 100vw, 618px\" \/><\/p>\n<p>Please note if you want to remove the relationship then you can use Unrelate Records step and that also require same properties as Relate records step.<\/p>\n<p>Result: &#8211; Please check below screenshot when we created a contact in CRM and flow got triggered respectively.<\/p>\n<p><img decoding=\"async\" class=\"aligncenter size-full wp-image-22916\" src=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2020\/02\/6Associate-and-disassociate-two-entities.png\" alt=\"Associate and disassociate two entities\" width=\"970\" height=\"300\" srcset=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2020\/02\/6Associate-and-disassociate-two-entities.png 970w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2020\/02\/6Associate-and-disassociate-two-entities-300x93.png 300w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2020\/02\/6Associate-and-disassociate-two-entities-768x238.png 768w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2020\/02\/6Associate-and-disassociate-two-entities-660x204.png 660w\" sizes=\"(max-width: 970px) 100vw, 970px\" \/><\/p>\n<p><img decoding=\"async\" class=\"aligncenter size-full wp-image-22917\" src=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2020\/02\/7Associate-and-disassociate-two-entities.png\" alt=\"Associate and disassociate two entities\" width=\"1095\" height=\"526\" srcset=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2020\/02\/7Associate-and-disassociate-two-entities.png 1095w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2020\/02\/7Associate-and-disassociate-two-entities-300x144.png 300w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2020\/02\/7Associate-and-disassociate-two-entities-768x369.png 768w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2020\/02\/7Associate-and-disassociate-two-entities-1024x492.png 1024w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2020\/02\/7Associate-and-disassociate-two-entities-660x317.png 660w\" sizes=\"(max-width: 1095px) 100vw, 1095px\" \/><\/p>\n<p>&nbsp;<\/p>\n<h2>Conclusion<\/h2>\n<p>So, this is how using relate and unrelate records step we can associate or disassociate two entities, which has 1: N or N: N relationship between them.<\/p>\n<h2 style=\"text-align: left;\"><div class=\"su-heading su-heading-style-default su-heading-align-center\" id=\"\" style=\"font-size:15px;margin-bottom:5px\"><div class=\"su-heading-inner\">70% of global 2000 companies apply gamification to improve productivity and returns!<\/div><\/div><\/h2>\n<p><em><strong><a href=\"https:\/\/bit.ly\/3RD4lYW\" target=\"_blank\" rel=\"noopener noreferrer\">Gamifics365<\/a> <\/strong>\u2013 Spin the magic of games within Microsoft Dynamics 365 CRM to improve user adoption, enhance productivity, and achieve company goals!<\/em><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Introduction Power Automate has been introducing new features and one of them is \u2018Relate\/Unrelate Records\u2019 feature. This is a step towards new common data service connector and it supports 1: N, N: N relationships. Now, let\u2019s see with an example how it works. We have two entities \u2018Contact\u2019 and \u2018Web Role\u2019 and there is N:\u2026 <span class=\"read-more\"><a href=\"https:\/\/www.inogic.com\/blog\/2020\/02\/associate-disassociate-two-entities-with-1-n-and-n-n-relationship-using-relate-unrelate-records-in-power-automate\/\">Read More &raquo;<\/a><\/span><\/p>\n","protected":false},"author":13,"featured_media":22918,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"om_disable_all_campaigns":false,"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[16,18,19,1985],"tags":[2015],"class_list":["post-22910","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-dynamics-365","category-dynamics-365-v9-2","category-dynamics-crm","category-power-automate","tag-associate-disassociate-two-entities"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/posts\/22910","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/users\/13"}],"replies":[{"embeddable":true,"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/comments?post=22910"}],"version-history":[{"count":0,"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/posts\/22910\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/media\/22918"}],"wp:attachment":[{"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/media?parent=22910"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/categories?post=22910"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/tags?post=22910"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}