{"id":26897,"date":"2021-02-23T11:26:20","date_gmt":"2021-02-23T11:26:20","guid":{"rendered":"https:\/\/www.inogic.com\/blog\/?p=26897"},"modified":"2021-02-23T11:28:01","modified_gmt":"2021-02-23T11:28:01","slug":"execution-context-for-cds-current-environment-connector-in-power-automate-flows-explained","status":"publish","type":"post","link":"https:\/\/www.inogic.com\/blog\/2021\/02\/execution-context-for-cds-current-environment-connector-in-power-automate-flows-explained\/","title":{"rendered":"Execution Context for CDS (Current Environment) Connector in Power Automate Flows Explained"},"content":{"rendered":"<p style=\"text-align: justify;\">Power Automate Flows are executed as an asynchronous background execution. It is important to understand the execution context being used for all the steps\/actions designed in the flow for audit purposes.<\/p>\n<p style=\"text-align: justify;\">Prior to this setting being made available, you needed to associate a connection with every action and the action was executed under the context of that user irrespective of who performed the initial action that triggered the flow in the first place.<\/p>\n<p><img decoding=\"async\" class=\"aligncenter size-full wp-image-26898\" style=\"border: 1px solid #0a0a0a; padding: 1px; margin: 1px;\" src=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2021\/02\/CDS_1.png\" alt=\"\" width=\"1716\" height=\"928\" srcset=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2021\/02\/CDS_1.png 1716w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2021\/02\/CDS_1-300x162.png 300w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2021\/02\/CDS_1-768x415.png 768w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2021\/02\/CDS_1-1024x554.png 1024w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2021\/02\/CDS_1-660x357.png 660w\" sizes=\"(max-width: 1716px) 100vw, 1716px\" \/><\/p>\n<p>This way the context was always hardcoded at design time and it wasn\u2019t very helpful for audit tracking and enforcing privileges.<\/p>\n<p style=\"text-align: justify;\">Let us take an example to understand this better. Say we create a flow that triggers on the create\/update of a record and is supposed to create an audit log entry to record the details of the user that performed the changes.<\/p>\n<p style=\"text-align: justify;\">With the above setting, the record will be created but the owner of the record would always be set to user specified in the connection i.e., Roohi even though the action was triggered by another user \u201cSam\u201d in the below example.<\/p>\n<p><img decoding=\"async\" class=\"aligncenter size-full wp-image-26899\" style=\"border: 1px solid #0a0a0a; padding: 1px; margin: 1px;\" src=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2021\/02\/CDS_2.png\" alt=\"\" width=\"1818\" height=\"162\" srcset=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2021\/02\/CDS_2.png 1818w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2021\/02\/CDS_2-300x27.png 300w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2021\/02\/CDS_2-768x68.png 768w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2021\/02\/CDS_2-1024x91.png 1024w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2021\/02\/CDS_2-660x59.png 660w\" sizes=\"(max-width: 1818px) 100vw, 1818px\" \/><\/p>\n<p style=\"text-align: justify;\">With the Run as option added to the trigger of CDS (Current Environment) connector, now you are able to specify the user context under which the following actions should be performed.<\/p>\n<p><img decoding=\"async\" class=\"aligncenter wp-image-26900\" style=\"border: 1px solid #0a0a0a; padding: 1px; margin: 1px;\" src=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2021\/02\/CDS_3.png\" alt=\"\" width=\"1162\" height=\"1080\" srcset=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2021\/02\/CDS_3.png 1162w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2021\/02\/CDS_3-300x279.png 300w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2021\/02\/CDS_3-768x714.png 768w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2021\/02\/CDS_3-1024x952.png 1024w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2021\/02\/CDS_3-660x613.png 660w\" sizes=\"(max-width: 1162px) 100vw, 1162px\" \/><\/p>\n<p>The options available are:-<\/p>\n<p style=\"text-align: justify;\"><strong>1) Triggering user \u2013<\/strong> You want the actions to be executed in the context of the user that invoked the trigger. For this you need to ensure that the Triggering user has the privileges to perform the action.<\/p>\n<p>In our example the triggering user should have privileges to create record in Audit Log entity.<\/p>\n<p>For this setting on the trigger to be honored make sure that every action is set to use Invokers connection as shown below:<\/p>\n<p><img decoding=\"async\" class=\"aligncenter size-full wp-image-26901\" style=\"border: 1px solid #0a0a0a; padding: 1px; margin: 1px;\" src=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2021\/02\/CDS_4.png\" alt=\"\" width=\"1654\" height=\"908\" srcset=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2021\/02\/CDS_4.png 1654w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2021\/02\/CDS_4-300x165.png 300w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2021\/02\/CDS_4-768x422.png 768w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2021\/02\/CDS_4-1024x562.png 1024w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2021\/02\/CDS_4-660x362.png 660w\" sizes=\"(max-width: 1654px) 100vw, 1654px\" \/><\/p>\n<p>With the Run as set to \u201cTriggering User\u201d, when a contact is updated by user Sam, the results now show up as:<\/p>\n<p><img decoding=\"async\" class=\"aligncenter size-full wp-image-26902\" style=\"border: 1px solid #0a0a0a; padding: 1px; margin: 1px;\" src=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2021\/02\/CDS_5.png\" alt=\"\" width=\"1654\" height=\"212\" srcset=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2021\/02\/CDS_5.png 1654w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2021\/02\/CDS_5-300x38.png 300w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2021\/02\/CDS_5-768x98.png 768w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2021\/02\/CDS_5-1024x131.png 1024w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2021\/02\/CDS_5-660x85.png 660w\" sizes=\"(max-width: 1654px) 100vw, 1654px\" \/><\/p>\n<p><strong>2) Record Owner \u2013<\/strong> In this case the actions are executed under the context of the owner of the record for which the flow was invoked.<\/p>\n<p><img decoding=\"async\" class=\"aligncenter size-full wp-image-26903\" style=\"border: 1px solid #0a0a0a; padding: 1px; margin: 1px;\" src=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2021\/02\/CDS_6.png\" alt=\"\" width=\"1140\" height=\"706\" srcset=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2021\/02\/CDS_6.png 1140w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2021\/02\/CDS_6-300x186.png 300w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2021\/02\/CDS_6-768x476.png 768w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2021\/02\/CDS_6-1024x634.png 1024w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2021\/02\/CDS_6-660x409.png 660w\" sizes=\"(max-width: 1140px) 100vw, 1140px\" \/><\/p>\n<p style=\"text-align: justify;\">Even though user Sam edited the record as can be identified from the user lookup set, the owner of the record continues to be David, who was set as the owner of the record that was edited.<\/p>\n<p><img decoding=\"async\" class=\"aligncenter size-full wp-image-26904\" style=\"border: 1px solid #0a0a0a; padding: 1px; margin: 1px;\" src=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2021\/02\/CDS_7.png\" alt=\"\" width=\"1654\" height=\"212\" srcset=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2021\/02\/CDS_7.png 1654w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2021\/02\/CDS_7-300x38.png 300w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2021\/02\/CDS_7-768x98.png 768w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2021\/02\/CDS_7-1024x131.png 1024w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2021\/02\/CDS_7-660x85.png 660w\" sizes=\"(max-width: 1654px) 100vw, 1654px\" \/><\/p>\n<p><strong>3) Process Owner \u2013<\/strong> The actions will be executed under the context of the user whose connection has been selected for the trigger.<\/p>\n<p>Here is what the flow looks like:<\/p>\n<p>Flow was created by the user Soul S. There are 2 connections:<\/p>\n<ol>\n<li>Using Soul s credentials<\/li>\n<li>Using Roohi credentials<\/li>\n<\/ol>\n<p><img decoding=\"async\" class=\"aligncenter size-full wp-image-26905\" style=\"border: 1px solid #0a0a0a; padding: 1px; margin: 1px;\" src=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2021\/02\/CDS_8.png\" alt=\"\" width=\"1986\" height=\"734\" srcset=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2021\/02\/CDS_8.png 1986w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2021\/02\/CDS_8-300x111.png 300w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2021\/02\/CDS_8-768x284.png 768w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2021\/02\/CDS_8-1024x378.png 1024w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2021\/02\/CDS_8-660x244.png 660w\" sizes=\"(max-width: 1986px) 100vw, 1986px\" \/><\/p>\n<p>Within the flow, used the following connection for the trigger:<\/p>\n<p><img decoding=\"async\" class=\"aligncenter size-full wp-image-26906\" style=\"border: 1px solid #0a0a0a; padding: 1px; margin: 1px;\" src=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2021\/02\/CDS_9.png\" alt=\"\" width=\"1796\" height=\"1056\" srcset=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2021\/02\/CDS_9.png 1796w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2021\/02\/CDS_9-300x176.png 300w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2021\/02\/CDS_9-768x452.png 768w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2021\/02\/CDS_9-1024x602.png 1024w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2021\/02\/CDS_9-660x388.png 660w\" sizes=\"(max-width: 1796px) 100vw, 1796px\" \/><\/p>\n<p style=\"text-align: justify;\">Added 2 parallel actions both creates the audit log record but are set to Use Invokers connection, and one was set to use Roohi connection and the other Soul connection.<\/p>\n<p><img decoding=\"async\" class=\"aligncenter size-full wp-image-26907\" style=\"border: 1px solid #0a0a0a; padding: 1px; margin: 1px;\" src=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2021\/02\/CDS_10.png\" alt=\"\" width=\"1796\" height=\"1056\" srcset=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2021\/02\/CDS_10.png 1796w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2021\/02\/CDS_10-300x176.png 300w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2021\/02\/CDS_10-768x452.png 768w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2021\/02\/CDS_10-1024x602.png 1024w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2021\/02\/CDS_10-660x388.png 660w\" sizes=\"(max-width: 1796px) 100vw, 1796px\" \/><\/p>\n<p style=\"text-align: justify;\">The result is \u2013 both records are created under the context of Roohi, the user that was setup at the trigger and not Soul who is the flow owner or creator.<\/p>\n<p><img decoding=\"async\" class=\"aligncenter size-full wp-image-26908\" style=\"border: 1px solid #0a0a0a; padding: 1px; margin: 1px;\" src=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2021\/02\/CDS_11.png\" alt=\"\" width=\"1826\" height=\"254\" srcset=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2021\/02\/CDS_11.png 1826w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2021\/02\/CDS_11-300x42.png 300w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2021\/02\/CDS_11-768x107.png 768w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2021\/02\/CDS_11-1024x142.png 1024w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2021\/02\/CDS_11-660x92.png 660w\" sizes=\"(max-width: 1826px) 100vw, 1826px\" \/><\/p>\n<p style=\"text-align: justify;\"><strong>4) If you leave the Run as blank \u2013<\/strong> it picks up the credentials and is executed under the context of the user\/connection set for each action if the Use Invoker\u2019s connection is unchecked.<\/p>\n<p><img decoding=\"async\" class=\"aligncenter size-full wp-image-26909\" style=\"border: 1px solid #0a0a0a; padding: 1px; margin: 1px;\" src=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2021\/02\/CDS_12.png\" alt=\"\" width=\"1246\" height=\"750\" srcset=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2021\/02\/CDS_12.png 1246w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2021\/02\/CDS_12-300x181.png 300w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2021\/02\/CDS_12-768x462.png 768w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2021\/02\/CDS_12-1024x616.png 1024w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2021\/02\/CDS_12-660x397.png 660w\" sizes=\"(max-width: 1246px) 100vw, 1246px\" \/><\/p>\n<p style=\"text-align: justify;\">In our example since one action was set to run under connection Roohi and the other Soul, the records created had the owners set accordingly.<\/p>\n<p><img decoding=\"async\" class=\"aligncenter size-full wp-image-26910\" style=\"border: 1px solid #0a0a0a; padding: 1px; margin: 1px;\" src=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2021\/02\/CDS_13.png\" alt=\"\" width=\"1826\" height=\"254\" srcset=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2021\/02\/CDS_13.png 1826w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2021\/02\/CDS_13-300x42.png 300w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2021\/02\/CDS_13-768x107.png 768w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2021\/02\/CDS_13-1024x142.png 1024w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2021\/02\/CDS_13-660x92.png 660w\" sizes=\"(max-width: 1826px) 100vw, 1826px\" \/><\/p>\n<p><strong>5)<\/strong> If you leave the Run as blank and the Use Invoker\u2019s connection is checked on every action;<\/p>\n<p><img decoding=\"async\" class=\"aligncenter size-full wp-image-26911\" style=\"border: 1px solid #0a0a0a; padding: 1px; margin: 1px;\" src=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2021\/02\/CDS_14.png\" alt=\"\" width=\"1836\" height=\"880\" srcset=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2021\/02\/CDS_14.png 1836w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2021\/02\/CDS_14-300x144.png 300w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2021\/02\/CDS_14-768x368.png 768w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2021\/02\/CDS_14-1024x491.png 1024w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2021\/02\/CDS_14-660x316.png 660w\" sizes=\"(max-width: 1836px) 100vw, 1836px\" \/><\/p>\n<p>then it is executed under the context of the user that invoked the action similar to Triggering User.<\/p>\n<p><img decoding=\"async\" class=\"aligncenter size-full wp-image-26912\" style=\"border: 1px solid #0a0a0a; padding: 1px; margin: 1px;\" src=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2021\/02\/CDS_15.png\" alt=\"\" width=\"1346\" height=\"254\" srcset=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2021\/02\/CDS_15.png 1346w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2021\/02\/CDS_15-300x57.png 300w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2021\/02\/CDS_15-768x145.png 768w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2021\/02\/CDS_15-1024x193.png 1024w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2021\/02\/CDS_15-660x125.png 660w\" sizes=\"(max-width: 1346px) 100vw, 1346px\" \/><\/p>\n<p style=\"text-align: justify;\">Depending on the scenarios you can now choose the execution context under which the flow actions should be executed. For anything to be executed under admin privileges, you could go for \u201cProcess Owner\u201d and set up the credentials of Super User, or if you need actions to be performed under the context of logged-in user choose the \u201cTriggering User\u201d option.<\/p>\n<p><a href=\"https:\/\/www.inogic.com\/product\/productivity-apps\/click-2-clone-microsoft-dynamics-crm-records\" target=\"_blank\" rel=\"noopener noreferrer\"><img decoding=\"async\" class=\"aligncenter size-full wp-image-26913\" src=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2021\/02\/C2C-1.jpg\" alt=\"\" width=\"800\" height=\"200\" srcset=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2021\/02\/C2C-1.jpg 800w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2021\/02\/C2C-1-300x75.jpg 300w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2021\/02\/C2C-1-768x192.jpg 768w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2021\/02\/C2C-1-660x165.jpg 660w\" sizes=\"(max-width: 800px) 100vw, 800px\" \/><\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Power Automate Flows are executed as an asynchronous background execution. It is important to understand the execution context being used for all the steps\/actions designed in the flow for audit purposes. Prior to this setting being made available, you needed to associate a connection with every action and the action was executed under the context\u2026 <span class=\"read-more\"><a href=\"https:\/\/www.inogic.com\/blog\/2021\/02\/execution-context-for-cds-current-environment-connector-in-power-automate-flows-explained\/\">Read More &raquo;<\/a><\/span><\/p>\n","protected":false},"author":13,"featured_media":0,"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":[9,2088,28,1985],"tags":[2135,1989],"class_list":["post-26897","post","type-post","status-publish","format-standard","hentry","category-common-data-service","category-custom-connector","category-flow","category-power-automate","tag-cds-connector","tag-power-automate-flows"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/posts\/26897","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=26897"}],"version-history":[{"count":0,"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/posts\/26897\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/media?parent=26897"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/categories?post=26897"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/tags?post=26897"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}