{"id":642,"date":"2020-01-14T18:16:39","date_gmt":"2020-01-14T17:16:39","guid":{"rendered":"http:\/\/wp.bizoir.dk\/?p=642"},"modified":"2020-01-14T18:16:39","modified_gmt":"2020-01-14T17:16:39","slug":"differentiate-between-multiple-triggers-in-a-logic-app","status":"publish","type":"post","link":"https:\/\/wp.bizoir.dk\/?p=642","title":{"rendered":"Differentiate between Multiple triggers in a Logic App"},"content":{"rendered":"<p>In some cases, you might want to use more than one trigger in a Logic App. This can for instance be when you hook up to a D365 CE environment and use the &#8220;Common Data Service&#8221; Connector in Logic Apps to subscribe to changes<\/p>\n<p>Here, it might make sense to have two triggers (one for the event &#8220;When_a_record_is_created&#8221; and one for the event &#8220;When_a_record_is_updated&#8221;) since both can often be handled similarly &#8211; at least if you are inserting or updating them in a SQL-server.<br \/>\nThis is easy to do, since you in the following actions always can refer to &#8220;@triggerbody()&#8221; no matter which trigger has fired.<\/p>\n<p>But what can you do, if you also would like to include the &#8220;When_a_record_is_deleted&#8221; trigger in the same Logic App. It potentially could be handled by the same Stored Procedure (for instance), but where the data from CDS is similar whether it is a &#8220;created&#8221; or an &#8220;updated&#8221; event, CE only sends the CE record GUID when it triggers the &#8220;deleted&#8221; event. This would probably make it less obvious to use the same handling for all 3 triggers.<\/p>\n<p>You can actually query the logic app, for which trigger was in fact triggered. You can use the &#8220;@trigger()?[&#8216;name&#8217;]&#8221; in a condition to compare it with trigger-names and behave differently depending on the trigger.<\/p>\n<p>It can very well be argued, if it is a good idea to pack both INSERT, UPDATE and DELETE handling into one single Logic App, but in our case we are having a LOT of Logic Apps already, and it clutters the view the more Logic Apps are added. Also, the CE tables in question are small, seldom-updated tables.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In some cases, you might want to use more than one trigger in a Logic App. This can for instance be when you hook up to a D365 CE environment and use the &#8220;Common Data Service&#8221; Connector in Logic Apps to subscribe to changes Here, it might make sense to have two triggers (one for &hellip; <a href=\"https:\/\/wp.bizoir.dk\/?p=642\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Differentiate between Multiple triggers in a Logic App&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[9],"tags":[36],"class_list":["post-642","post","type-post","status-publish","format-standard","hentry","category-guides","tag-logic-apps"],"_links":{"self":[{"href":"https:\/\/wp.bizoir.dk\/index.php?rest_route=\/wp\/v2\/posts\/642","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wp.bizoir.dk\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/wp.bizoir.dk\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/wp.bizoir.dk\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/wp.bizoir.dk\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=642"}],"version-history":[{"count":1,"href":"https:\/\/wp.bizoir.dk\/index.php?rest_route=\/wp\/v2\/posts\/642\/revisions"}],"predecessor-version":[{"id":643,"href":"https:\/\/wp.bizoir.dk\/index.php?rest_route=\/wp\/v2\/posts\/642\/revisions\/643"}],"wp:attachment":[{"href":"https:\/\/wp.bizoir.dk\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=642"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/wp.bizoir.dk\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=642"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/wp.bizoir.dk\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=642"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}