{"id":42063,"date":"2025-08-21T14:16:43","date_gmt":"2025-08-21T08:46:43","guid":{"rendered":"https:\/\/www.inogic.com\/blog\/?p=42063"},"modified":"2025-08-21T14:16:43","modified_gmt":"2025-08-21T08:46:43","slug":"retrieve-and-validate-field-associated-workflows-in-dynamics-365-dataverse","status":"publish","type":"post","link":"https:\/\/www.inogic.com\/blog\/2025\/08\/retrieve-and-validate-field-associated-workflows-in-dynamics-365-dataverse\/","title":{"rendered":"Retrieve and Validate Field Associated Workflows in Dynamics 365\/Dataverse"},"content":{"rendered":"<p><img decoding=\"async\" class=\"alignnone size-full wp-image-42064\" src=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2025\/08\/Retrieve-and-Validate-Field-Associated-Workflows-in-Dynamics-365Dataverse.png\" alt=\"Retrieve and Validate Field Associated Workflows in Dynamics 365Dataverse\" width=\"2100\" height=\"1200\" srcset=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2025\/08\/Retrieve-and-Validate-Field-Associated-Workflows-in-Dynamics-365Dataverse.png 2100w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2025\/08\/Retrieve-and-Validate-Field-Associated-Workflows-in-Dynamics-365Dataverse-300x171.png 300w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2025\/08\/Retrieve-and-Validate-Field-Associated-Workflows-in-Dynamics-365Dataverse-1024x585.png 1024w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2025\/08\/Retrieve-and-Validate-Field-Associated-Workflows-in-Dynamics-365Dataverse-768x439.png 768w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2025\/08\/Retrieve-and-Validate-Field-Associated-Workflows-in-Dynamics-365Dataverse-1536x878.png 1536w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2025\/08\/Retrieve-and-Validate-Field-Associated-Workflows-in-Dynamics-365Dataverse-2048x1170.png 2048w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2025\/08\/Retrieve-and-Validate-Field-Associated-Workflows-in-Dynamics-365Dataverse-660x377.png 660w\" sizes=\"(max-width: 2100px) 100vw, 2100px\" \/><\/p>\n<p>Workflows (also known as processes) in Dynamics 365 automate business logic such as approvals, field updates, or triggering other workflow actions. Sometimes, we need to <strong>check whether a workflow exists for a specific field <\/strong>before performing an action on a form.<\/p>\n<p>For example, when updating sensitive fields like Credit Limit or Risk Category, you may want to warn users if workflows are already associated with these fields, since saving the record could trigger important automated processes.<\/p>\n<p>In this blog, we\u2019ll explore:<\/p>\n<ul>\n<li>Workflow categories and what they mean.<\/li>\n<li>How to retrieve workflows related to a specific field.<\/li>\n<li>A practical implementation where we check workflows before setting a Risk Category<\/li>\n<\/ul>\n<h2><strong>Workflow Categories in Dynamics 365<\/strong><\/h2>\n<p>In Dynamics 365, every workflow or process is assigned a Category value in the workflow table. For detailed insights into <a href=\"https:\/\/learn.microsoft.com\/en-us\/power-apps\/developer\/data-platform\/webapi\/reference\/workflow?view=dataverse-latest\">workflow properties<\/a>, you can always check Microsoft\u2019s official documentation for the latest updates. Below are the key category values:<\/p>\n<table width=\"326\">\n<tbody>\n<tr>\n<td width=\"120\"><strong>Category Value<\/strong><\/td>\n<td width=\"205\"><strong>Workflow Type<\/strong><\/td>\n<\/tr>\n<tr>\n<td width=\"120\">0<\/td>\n<td width=\"205\">Classic Workflow<\/td>\n<\/tr>\n<tr>\n<td width=\"120\">1<\/td>\n<td width=\"205\">Dialog<\/td>\n<\/tr>\n<tr>\n<td width=\"120\">2<\/td>\n<td width=\"205\">Business Rule<\/td>\n<\/tr>\n<tr>\n<td width=\"120\">3<\/td>\n<td width=\"205\">Action<\/td>\n<\/tr>\n<tr>\n<td width=\"120\">4<\/td>\n<td width=\"205\">Business Process Flow (BPF)<\/td>\n<\/tr>\n<tr>\n<td width=\"120\">5<\/td>\n<td width=\"205\">Modern Flow (Cloud Flow)<\/td>\n<\/tr>\n<tr>\n<td width=\"120\">6<\/td>\n<td width=\"205\">Desktop Flow<\/td>\n<\/tr>\n<tr>\n<td width=\"120\">7<\/td>\n<td width=\"205\">AI Flow<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h2><strong>Use Case<\/strong><\/h2>\n<p>Suppose you\u2019re handling the Account entity in Dynamics 365.<\/p>\n<ul>\n<li>When a user updates the Credit Limit, the system automatically sets the Risk Category (High, Medium, or Low).<\/li>\n<li>But before setting this field, we want to check if any workflows (category = 5, i.e., Cloud Flows) are already linked with this Risk Category field.<\/li>\n<li>If workflows exist, we show a confirmation pop-up to the user:<br \/>\n\u201cThere are workflows associated with this field. Saving may trigger them. Do you want to continue?\u201d<\/li>\n<\/ul>\n<p>This ensures users are aware of possible automated actions before proceeding.<\/p>\n<p><strong>Implementation in Power Apps (JavaScript on Form)<\/strong><\/p>\n<p>We\u2019ll add a JavaScript function to the onChange event of the Credit Limit field.<\/p>\n<h3><strong>Step 1: Retrieve Workflows from Dataverse<\/strong><\/h3>\n<p>We query the workflow table using Web API and filter by:<\/p>\n<ul>\n<li>Category = 5 (Cloud Flow)<\/li>\n<li>clientdata containing our field (in this case, cre44_riskcategory)<\/li>\n<\/ul>\n<p><strong>Code: <\/strong><\/p>\n<pre class=\"lang:css gutter:true start:1\">\/\/ Helper function to check if workflows exist for a given field\r\n\r\nasync function checkAssociatedWorkflows(fieldLogicalName) {\r\n\r\ntry {\r\n\r\nconst query = \"?$select=workflowid,name,clientdata\" + \"&amp;$filter=category eq 5 and contains(clientdata, '\" + fieldLogicalName.toLowerCase() + \"')\";\r\n\r\n\u00a0\r\n\r\nconst results = await Xrm.WebApi.retrieveMultipleRecords(\"workflow\", query);\r\n\r\n\u00a0\r\n\r\nreturn results.entities &amp;&amp; results.entities.length &gt; 0;\r\n\r\n} catch (error) {\r\n\r\nconsole.error(\"Error fetching workflows:\", error.message);\r\n\r\nreturn false; \/\/ fail safe \u2192 act like no workflows\r\n\r\n}\r\n\r\n}<\/pre>\n<p><strong>Step 2: Handle Credit Limit Change<\/strong><\/p>\n<p>When the <strong>Credit Limit<\/strong> changes, we determine the <strong>Risk Category<\/strong> value and then check workflows.<\/p>\n<p><strong>Code:<\/strong><\/p>\n<pre class=\"lang:css gutter:true start:1\">\/\/ Function: Called on Credit Limit field OnChange\r\n\r\nasync function onCreditLimitChange(executionContext) {\r\n\r\ntry {\r\n\r\nvar formContext = executionContext.getFormContext();\r\n\r\nvar creditLimit = formContext.getAttribute(\"creditlimit\").getValue();\r\n\r\n\u00a0\r\n\r\nif (creditLimit == null) return;\r\n\r\n\u00a0\r\n\r\n\/\/ Auto-set Risk Category based on Credit Limit\r\n\r\nlet riskCategoryValue = null; \/\/ OptionSet Values: 1=High, 2=Medium, 3=Low (example)\r\n\r\n\u00a0\r\n\r\nif (creditLimit &gt; 100000) {\r\n\r\nriskCategoryValue = 1; \/\/ High\r\n\r\n} else if (creditLimit &gt; 50000) {\r\n\r\nriskCategoryValue = 2; \/\/ Medium\r\n\r\n} else {\r\n\r\nriskCategoryValue = 3; \/\/ Low\r\n\r\n}\r\n\r\n\u00a0\r\n\r\n\/\/ Before setting High\/Medium, check workflows\r\n\r\nif (riskCategoryValue === 1 || riskCategoryValue === 2) {\r\n\r\nconst hasWorkflows = await checkAssociatedWorkflows(\"cre44_riskcategory\");\r\n\r\n\u00a0\r\n\r\nif (hasWorkflows) {\r\n\r\nXrm.Navigation.openConfirmDialog(\r\n\r\n{\r\n\r\ntitle: \"Workflows Detected\",\r\n\r\ntext: \"There are workflows associated with Risk Category. Setting it to High\/Medium may trigger them. Do you want to continue?\",\r\n\r\nconfirmButtonLabel: \"Yes, Continue\",\r\n\r\ncancelButtonLabel: \"No, Cancel\"\r\n\r\n}\r\n\r\n).then(function (result) {\r\n\r\nif (result.confirmed) {\r\n\r\n\/\/ User confirmed \u2192 set field\r\n\r\nformContext.getAttribute(\"cre44_riskcategory\").setValue(riskCategoryValue);\r\n\r\n} else {\r\n\r\n\/\/ User cancelled \u2192 reset field\r\n\r\nformContext.getAttribute(\"cre44_riskcategory\").setValue(null);\r\n\r\n}\r\n\r\n});\r\n\r\n} else {\r\n\r\n\/\/ No workflows \u2192 set directly\r\n\r\nformContext.getAttribute(\"cre44_riskcategory\").setValue(riskCategoryValue);\r\n\r\n}\r\n\r\n} else {\r\n\r\n\/\/ Low risk \u2192 set directly\r\n\r\nformContext.getAttribute(\"cre44_riskcategory\").setValue(riskCategoryValue);\r\n\r\n}\r\n\r\n} catch (error) {\r\n\r\nXrm.Navigation.openAlertDialog({\r\n\r\ntitle: \"Error\",\r\n\r\ntext: \"A failure occurred in Web API.\\nDetails: \" + error.message\r\n\r\n});\r\n\r\n}\r\n\r\n}<\/pre>\n<h3><strong>Execution in Account Form<\/strong><\/h3>\n<p>1. Add the provided JavaScript web resource within your Dynamics 365 solution.<\/p>\n<p><img decoding=\"async\" class=\"alignnone size-full wp-image-42065\" style=\"border: 1px solid #000000; padding: 1px; margin: 1px;\" src=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2025\/08\/Validate-Field-Associated-Workflows-in-Dynamics-365.png\" alt=\"Validate Field Associated Workflows in Dynamics 365\" width=\"2048\" height=\"929\" srcset=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2025\/08\/Validate-Field-Associated-Workflows-in-Dynamics-365.png 2048w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2025\/08\/Validate-Field-Associated-Workflows-in-Dynamics-365-300x136.png 300w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2025\/08\/Validate-Field-Associated-Workflows-in-Dynamics-365-1024x465.png 1024w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2025\/08\/Validate-Field-Associated-Workflows-in-Dynamics-365-768x348.png 768w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2025\/08\/Validate-Field-Associated-Workflows-in-Dynamics-365-1536x697.png 1536w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2025\/08\/Validate-Field-Associated-Workflows-in-Dynamics-365-660x299.png 660w\" sizes=\"(max-width: 2048px) 100vw, 2048px\" \/><\/p>\n<p>2. On the Account form, bind the onCreditLimitChange function to the Credit Limit field\u2019s OnChange event.<\/p>\n<p><img decoding=\"async\" class=\"alignnone size-full wp-image-42066\" style=\"border: 1px solid #000000; padding: 1px; margin: 1px;\" src=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2025\/08\/1Validate-Field-Associated-Workflows-in-Dynamics-365.png\" alt=\"Validate Field Associated Workflows in Dynamics 365\" width=\"2048\" height=\"929\" srcset=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2025\/08\/1Validate-Field-Associated-Workflows-in-Dynamics-365.png 2048w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2025\/08\/1Validate-Field-Associated-Workflows-in-Dynamics-365-300x136.png 300w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2025\/08\/1Validate-Field-Associated-Workflows-in-Dynamics-365-1024x465.png 1024w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2025\/08\/1Validate-Field-Associated-Workflows-in-Dynamics-365-768x348.png 768w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2025\/08\/1Validate-Field-Associated-Workflows-in-Dynamics-365-1536x697.png 1536w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2025\/08\/1Validate-Field-Associated-Workflows-in-Dynamics-365-660x299.png 660w\" sizes=\"(max-width: 2048px) 100vw, 2048px\" \/><\/p>\n<p>3. Publish and test:<\/p>\n<p>If workflows exist for Risk Category (and it\u2019s set to High\/Medium), you\u2019ll get a <strong>confirmation popup<\/strong>, and if no workflows exist, the field is updated directly.<\/p>\n<p><img decoding=\"async\" class=\"alignnone size-full wp-image-42067\" style=\"border: 1px solid #000000; padding: 1px; margin: 1px;\" src=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2025\/08\/2Validate-Field-Associated-Workflows-in-Dynamics-365.png\" alt=\"alidate Field Associated Workflows in Dynamics 365\" width=\"2048\" height=\"929\" srcset=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2025\/08\/2Validate-Field-Associated-Workflows-in-Dynamics-365.png 2048w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2025\/08\/2Validate-Field-Associated-Workflows-in-Dynamics-365-300x136.png 300w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2025\/08\/2Validate-Field-Associated-Workflows-in-Dynamics-365-1024x465.png 1024w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2025\/08\/2Validate-Field-Associated-Workflows-in-Dynamics-365-768x348.png 768w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2025\/08\/2Validate-Field-Associated-Workflows-in-Dynamics-365-1536x697.png 1536w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2025\/08\/2Validate-Field-Associated-Workflows-in-Dynamics-365-660x299.png 660w\" sizes=\"(max-width: 2048px) 100vw, 2048px\" \/><\/p>\n<h2><strong>Summary<\/strong><\/h2>\n<ul>\n<li>Workflows in Dynamics 365 are categorized by type (Classic, Dialog, Action, BPF, Cloud Flow).<\/li>\n<li>Retrieve workflows from the workflow table by executing Web API queries.<\/li>\n<li>In our example, we checked for <strong>Cloud Flows (category 5)<\/strong> linked to the <strong>Risk Category field<\/strong> before updating it.<\/li>\n<li>This approach adds a safety layer, ensuring users are aware of automation that might get triggered.<\/li>\n<\/ul>\n<p>This method is very useful when dealing with <strong>sensitive fields<\/strong> like Credit Limit, Risk Category, or Approval fields in Dynamics 365.<\/p>\n<h3><strong>Conclusion<\/strong><\/h3>\n<p>Identifying workflows linked to specific fields in Dynamics 365 helps avoid unexpected automation. It ensures better control while updating sensitive fields like Credit Limit or Risk Category. This improves system reliability and reduces troubleshooting efforts. Overall, it empowers admins to manage workflows with confidence.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Workflows (also known as processes) in Dynamics 365 automate business logic such as approvals, field updates, or triggering other workflow actions. Sometimes, we need to check whether a workflow exists for a specific field before performing an action on a form. For example, when updating sensitive fields like Credit Limit or Risk Category, you may\u2026 <span class=\"read-more\"><a href=\"https:\/\/www.inogic.com\/blog\/2025\/08\/retrieve-and-validate-field-associated-workflows-in-dynamics-365-dataverse\/\">Read More &raquo;<\/a><\/span><\/p>\n","protected":false},"author":15,"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":[2354,2361],"tags":[3210],"class_list":["post-42063","post","type-post","status-publish","format-standard","hentry","category-dataverse","category-technical","tag-retrieve-and-validate-field-associated-workflows-in-dynamics-365"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/posts\/42063","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\/15"}],"replies":[{"embeddable":true,"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/comments?post=42063"}],"version-history":[{"count":0,"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/posts\/42063\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/media?parent=42063"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/categories?post=42063"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/tags?post=42063"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}