{"id":39659,"date":"2024-11-11T17:11:58","date_gmt":"2024-11-11T11:41:58","guid":{"rendered":"https:\/\/www.inogic.com\/blog\/?p=39659"},"modified":"2024-11-11T17:53:29","modified_gmt":"2024-11-11T12:23:29","slug":"how-to-bypass-custom-synchronous-and-asynchronous-business-logic-in-dynamics-365","status":"publish","type":"post","link":"https:\/\/www.inogic.com\/blog\/2024\/11\/how-to-bypass-custom-synchronous-and-asynchronous-business-logic-in-dynamics-365\/","title":{"rendered":"How to Bypass Custom Synchronous and Asynchronous Business Logic in Dynamics 365"},"content":{"rendered":"<p><img decoding=\"async\" class=\"alignnone size-full wp-image-39662\" src=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2024\/11\/Bypass-Custom-Synchronous-and-Asynchronous-Business-Logic-in-Dynamics-365.png\" alt=\"Bypass Custom Synchronous and Asynchronous Business Logic in Dynamics 365\" width=\"2800\" height=\"1600\" srcset=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2024\/11\/Bypass-Custom-Synchronous-and-Asynchronous-Business-Logic-in-Dynamics-365.png 2800w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2024\/11\/Bypass-Custom-Synchronous-and-Asynchronous-Business-Logic-in-Dynamics-365-300x171.png 300w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2024\/11\/Bypass-Custom-Synchronous-and-Asynchronous-Business-Logic-in-Dynamics-365-1024x585.png 1024w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2024\/11\/Bypass-Custom-Synchronous-and-Asynchronous-Business-Logic-in-Dynamics-365-768x439.png 768w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2024\/11\/Bypass-Custom-Synchronous-and-Asynchronous-Business-Logic-in-Dynamics-365-1536x878.png 1536w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2024\/11\/Bypass-Custom-Synchronous-and-Asynchronous-Business-Logic-in-Dynamics-365-2048x1170.png 2048w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2024\/11\/Bypass-Custom-Synchronous-and-Asynchronous-Business-Logic-in-Dynamics-365-660x377.png 660w\" sizes=\"(max-width: 2800px) 100vw, 2800px\" \/><\/p>\n<p>In Microsoft Dynamics 365, plugins and workflows are powerful tools for automating business processes and logic. These automations can be synchronous (sync) or asynchronous (async) and are typically designed to trigger based on specific business events. However, there are scenarios where you might want to bypass these custom business logics. For such cases, Microsoft provides a mechanism called BypassBusinessLogicExecution.<\/p>\n<p><strong>BypassBusinessLogicExecution<\/strong> is a feature that allows you to temporarily bypass the execution of custom plugins, workflows, and other business logic for specific operations. This can be particularly useful in situations where you need to perform bulk updates, data imports, or other administrative tasks where the usual business logic does not need to be applied.<\/p>\n<p>We were importing the Bulk Data and we have our own business logic. When a contact record gets created, the note should also get created.<\/p>\n<p>Now when I import the bulk contact records, I don\u2019t want to create any notes. Sure, I can find and disable all the plugins and workflows related to the creation of contact records. But that would be a hectic task to perform. Here I can use Bypass all Custom Business Logics in my environment.<\/p>\n<p><strong>Note<\/strong>: When you send requests that bypass custom business logic, all custom plug-ins and workflows are disabled except plugins and workflows where Microsoft is the publisher.<\/p>\n<p><strong>BypassBusinessLogicExecution<\/strong> is an optional parameter that targets the custom business logic applied for your organisation.<\/p>\n<p>There are two values for this parameter that we can use to define what type of logic we want to bypass:<\/p>\n<ol>\n<li><strong>CustomSync<\/strong> &#8212; Bypass only synchronous custom logic.<\/li>\n<li><strong>CustomAsync<\/strong> &#8212; Bypass only asynchronous custom logic, excluding Power Automate Flows.<\/li>\n<li><strong>CustomSync,CustomAsync<\/strong> &#8212; Bypass both synchronous and asynchronous custom logic, excluding Power Automate Flows.<\/li>\n<\/ol>\n<p>There is a prerequisite we need to follow before using this:<\/p>\n<p>The user initiating the requests must hold the <strong>prvBypassCustomBusinessLogic <\/strong>privilege, which is, by default, granted only to users with the system administrator security role.<\/p>\n<p><strong>prvBypassCustomBusinessLogic<\/strong>\u00a0user privilege can only be given by code there is no user\u00a0\u00a0\u00a0\u00a0 interface to give this user role.<\/p>\n<p><strong>Create a request for Synchronous Logics.<\/strong><\/p>\n<pre class=\"lang:css gutter:true start:1\">Entity Contact = new(\"contact\");\r\n\r\ncontact [\"firstname\"] = \"John\";\r\n\r\ncontact [\"lastname\"] = \"Doe\";\r\n\r\nCreateRequest request = new()\u00a0\u00a0\u00a0 {\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Target = account\u00a0\u00a0\u00a0 };\r\n\r\nrequest.Parameters.Add(\"BypassBusinessLogicExecution\", \"CustomSync \");\r\n\r\nservice.Execute(request);<\/pre>\n<p><strong>Create Request for Asynchronous Logic.<\/strong><\/p>\n<pre class=\"lang:css gutter:true start:1\">Entity Contact = new(\"contact\");\r\n\r\ncontact [\"firstname\"] = \"John\";\r\n\r\ncontact [\"lastname\"] = \"Doe\";\r\n\r\nCreateRequest request = new()\u00a0\u00a0\u00a0 {\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Target = account\u00a0\u00a0\u00a0 };\r\n\r\nrequest.Parameters.Add(\"BypassBusinessLogicExecution\", \"CustomAsync \");\r\n\r\nservice.Execute(request);<\/pre>\n<p><strong>Or we can bypass Both at the same time. <\/strong><\/p>\n<pre class=\"lang:css gutter:true start:1\">Entity Contact = new(\"contact\");\r\n\r\ncontact [\"firstname\"] = \"John\";\r\n\r\ncontact [\"lastname\"] = \"Doe\";\r\n\r\nCreateRequest request = new()\u00a0\u00a0\u00a0 {\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Target = account\u00a0\u00a0\u00a0 };\r\n\r\nrequest.Parameters.Add(\"BypassBusinessLogicExecution\", \"CustomSync, CustomAsync \");\r\n\r\nservice.Execute(request);<\/pre>\n<p>Let\u2019s See how can we assign this <strong>prvBypassCustomBusinessLogic<\/strong>\u00a0privilege to a security role via code:<\/p>\n<p>The ID for the\u00a0<strong>prvBypassCustomBusinessLogic<\/strong>\u00a0privilege is<\/p>\n<p>\u201c<strong>0ea552b0-a491-4470-9a1b-82068deccf66<\/strong>\u201d.<\/p>\n<pre class=\"lang:css gutter:true start:1\">var request = new AddPrivilegesRoleRequest\r\n\r\n{\r\n\r\nRoleId = yourSecurityRoleId,\r\n\r\nPrivileges = new[]{\r\n\r\nnew RolePrivilege{\r\n\r\nPrivilegeId = new Guid(\"0ea552b0-a491-4470-9a1b-82068deccf66\"),\r\n\r\nDepth = PrivilegeDepth.Global\r\n\r\n}\r\n\r\n}\r\n\r\n};\r\n\r\nservice.Execute(request);<\/pre>\n<p><strong>Bypassing Specific Plugins<\/strong><\/p>\n<p>You can bypass specific plugins by passing the step IDs:<\/p>\n<p>request.Parameters.Add(&#8220;<strong>BypassBusinessLogicExecutionStepIds<\/strong>&#8220;, &#8220;45e0c603-0d0b-466e-a286-d7fc1cda8361,d5370603-e4b9-4b92-b765-5966492a4fd7&#8221;);<\/p>\n<p>You can find the step IDs in the Plugin Registration Tool.<\/p>\n<p>By default, you can add up to 3 step IDs when bypassing plugins. This limit can be adjusted through the `<strong>BypassBusinessLogicExecutionStepIdsLimit<\/strong>` setting in the Organization Settings.<\/p>\n<p>Although <strong>BypassCustomPluginExecution<\/strong> is still supported, it&#8217;s recommended to use <strong>BypassBusinessLogicExecution<\/strong> with the <strong>CustomSync<\/strong> value for similar results.<\/p>\n<h2><strong>Conclusion<\/strong><\/h2>\n<p>BypassBusinessLogicExecution in Dynamics 365 allows admins to streamline bulk data imports and updates by temporarily bypassing custom business logic. This feature saves time and simplifies data management, making it an invaluable tool for efficient operations.<\/p>\n<p><a href=\"https:\/\/www.inogic.com\/product\/productivity-apps\/business-process-dynamics-365-crm-to-do-checklist-sequence\/\" target=\"_blank\" rel=\"noopener\"><img decoding=\"async\" class=\"alignnone size-full wp-image-37276\" src=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2024\/02\/Business-Process-Checklist-2.gif\" alt=\"Business Process Checklist\" width=\"800\" height=\"200\" \/><\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>In Microsoft Dynamics 365, plugins and workflows are powerful tools for automating business processes and logic. These automations can be synchronous (sync) or asynchronous (async) and are typically designed to trigger based on specific business events. However, there are scenarios where you might want to bypass these custom business logics. For such cases, Microsoft provides\u2026 <span class=\"read-more\"><a href=\"https:\/\/www.inogic.com\/blog\/2024\/11\/how-to-bypass-custom-synchronous-and-asynchronous-business-logic-in-dynamics-365\/\">Read More &raquo;<\/a><\/span><\/p>\n","protected":false},"author":11,"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":[1],"tags":[2962],"class_list":["post-39659","post","type-post","status-publish","format-standard","hentry","category-uncategorized","tag-synchronous-and-asynchronous-business-logic"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/posts\/39659","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\/11"}],"replies":[{"embeddable":true,"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/comments?post=39659"}],"version-history":[{"count":0,"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/posts\/39659\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/media?parent=39659"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/categories?post=39659"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/tags?post=39659"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}