{"id":10971,"date":"2018-01-04T15:19:59","date_gmt":"2018-01-04T09:49:59","guid":{"rendered":"https:\/\/www.inogic.com\/blog\/?p=10971"},"modified":"2018-01-04T15:19:59","modified_gmt":"2018-01-04T09:49:59","slug":"fixed-executing-action-with-complex-output-parameters-through-web-api-in-dynamics-365-v9-0","status":"publish","type":"post","link":"https:\/\/www.inogic.com\/blog\/2018\/01\/fixed-executing-action-with-complex-output-parameters-through-web-api-in-dynamics-365-v9-0\/","title":{"rendered":"Fixed &#8211; Executing Action with Complex Output Parameters through Web API in Dynamics 365 v9.0"},"content":{"rendered":"<h2 style=\"text-align: justify;\"><strong>Introduction:\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <\/strong><\/h2>\n<p>While working on Dynamics 365, we get a chance to work on lot many things.<\/p>\n<p>At times you work on C# or JavaScript or SSRS or SSIS. Having knowledge of so many languages, frameworks, or technologies could be taxing.<\/p>\n<p>Sometimes we face errors while developing something and don\u2019t have control over how it could be fixed.<\/p>\n<p style=\"text-align: justify;\">One such thing was executing Action using Web API.<\/p>\n<p style=\"text-align: justify;\">Prior to v9.0 update, if we tried executing Actions, having combination of complex and simple output parameters would result in errors like, <strong>Resource not found for the segment &#8216;ActionName&#8217; <\/strong>or<strong> Request message has unresolved parameters<\/strong>.<\/p>\n<p style=\"text-align: justify;\">In order to understand what complex and simple parameters are, please check a very well explained <a href=\"http:\/\/butenko.pro\/2016\/09\/23\/action-not-available-webapi\/\" target=\"_blank\" rel=\"noopener noreferrer\">blog<\/a> written by Andrew Butenko.<\/p>\n<p style=\"text-align: justify;\">Now, in v9.0 we don\u2019t have to worry about the combinations of the output parameters.<\/p>\n<p style=\"text-align: justify;\">Irrespective of the combination of the output parameters, we are able to execute the Action.<\/p>\n<h2 style=\"text-align: justify;\"><strong>Code Snippet:<\/strong><\/h2>\n<pre class=\"lang:default decode:true \">function executeAction(accountId, actionName, clientUrl) {\n    var functionName = \"executeAction &gt;&gt;\";\n    var query = \"\";\n    try {\n\n        \/\/Define the query to execute the action\n        query = \"accounts(\" + accountId + \")\/Microsoft.Dynamics.CRM.\"+actionName;\n\n        var req = new XMLHttpRequest();\n        req.open(\"POST\", clientUrl + \"\/api\/data\/v9.0\/\" + query, true);\n        req.setRequestHeader(\"Accept\", \"application\/json\");\n        req.setRequestHeader(\"Content-Type\", \"application\/json; charset=utf-8\");\n        req.setRequestHeader(\"OData-MaxVersion\", \"4.0\");\n        req.setRequestHeader(\"OData-Version\", \"4.0\");\n\n        req.onreadystatechange = function () {\n\n            if (this.readyState == 4 \/* complete *\/) {\n                req.onreadystatechange = null;\n\n                if (this.status == 200) {\n                    \/\/success callback\n                    var result = JSON.parse(this.response);\n\n\n                } else {\n                    \/\/error callback\n                    var error = JSON.parse(this.response).error;\n                }\n            }\n        };\n        req.send(JSON.stringify(data));\n\n    } catch (e) {\n        throwError(functionName, e);\n    }\n}\n<\/pre>\n<h2><strong>Conclusion:<\/strong><\/h2>\n<p>We can combine simple and complex output parameters and still execute the Action through Web API in Dynamics 365 v9.0<\/p>\n<p><a href=\"http:\/\/www.inogic.com\/product\/productivity-pack\/click-2-export-microsoft-dynamics-crm-reports\" target=\"_blank\" rel=\"noopener noreferrer\"><img decoding=\"async\" class=\"aligncenter  wp-image-10864\" src=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2017\/12\/Click2Export-banner.png\" alt=\"Export Dynamics CRM Reports\" width=\"824\" height=\"206\" \/><\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Introduction:\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 While working on Dynamics 365, we get a chance to work on lot many things. At times you work on C# or JavaScript or SSRS or SSIS. Having knowledge of so many languages, frameworks, or technologies could be taxing. Sometimes we face errors while developing something and don\u2019t have control over how it could\u2026 <span class=\"read-more\"><a href=\"https:\/\/www.inogic.com\/blog\/2018\/01\/fixed-executing-action-with-complex-output-parameters-through-web-api-in-dynamics-365-v9-0\/\">Read More &raquo;<\/a><\/span><\/p>\n","protected":false},"author":13,"featured_media":10972,"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,65],"tags":[1823,1824],"class_list":["post-10971","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-dynamics-365","category-dynamics-365-v9-2","category-dynamics-crm","category-webapi","tag-web-api-in-dynamics-365","tag-web-api-in-dynamics-365-v9-0"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/posts\/10971","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=10971"}],"version-history":[{"count":0,"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/posts\/10971\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/media\/10972"}],"wp:attachment":[{"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/media?parent=10971"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/categories?post=10971"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/tags?post=10971"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}