{"id":14994,"date":"2019-03-08T12:03:50","date_gmt":"2019-03-08T12:03:50","guid":{"rendered":"https:\/\/www.inogic.com\/blog\/?p=14994"},"modified":"2021-12-06T14:56:48","modified_gmt":"2021-12-06T09:26:48","slug":"retrieve-dynamics-365-crm-data-in-portal-by-calling-odata-using-javascript","status":"publish","type":"post","link":"https:\/\/www.inogic.com\/blog\/2019\/03\/retrieve-dynamics-365-crm-data-in-portal-by-calling-odata-using-javascript\/","title":{"rendered":"Retrieve Dynamics 365 CRM data in Portal by calling Odata using JavaScript"},"content":{"rendered":"<h2><strong>Introduction<\/strong><\/h2>\n<p style=\"text-align: justify;\">When user needs to display all the record using the \u201caccount\u201d entity on the portal page then he can perform the retrieve operation by calling OData query using JavaScript.<\/p>\n<h2><strong>Working<\/strong><\/h2>\n<p style=\"text-align: justify;\">First we will create the entity list. On the entity list there is tab \u201cOData\u201d where we need to fill the information like \u201cEntity Type Name\u201d, \u201cEntity Set Name\u201d, select the view and enable the Odata feed as shown in the below screenshot:<\/p>\n<p><img decoding=\"async\" class=\"aligncenter size-full wp-image-14995\" style=\"border: 1px solid #0a0a0a; padding: 1px; margin: 1px;\" src=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2019\/03\/1Retrieve-Dynamics-365-CRM-data-in-Portal-by-calling-Odata-using-JavaScript.png\" alt=\"Retrieve Dynamics 365 CRM data in Portal by calling Odata using JavaScript\" width=\"1113\" height=\"438\" \/><\/p>\n<p style=\"text-align: justify;\">Based on above configuration system we will generate Odata Based URL as\u00a0<strong>https:\/\/&lt;portalurl&gt;\/_odata\/entity_set_name<\/strong>, now we can retrieve the data on other webpages as well as show in the below screenshot<\/p>\n<p><img decoding=\"async\" class=\"aligncenter size-full wp-image-14996\" style=\"border: 1px solid #0a0a0a; padding: 1px; margin: 1px;\" src=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2019\/03\/2Retrieve-Dynamics-365-CRM-data-in-Portal-by-calling-Odata-using-JavaScript.png\" alt=\"Retrieve Dynamics 365 CRM data in Portal by calling Odata using JavaScript\" width=\"1232\" height=\"637\" \/><\/p>\n<p><strong>Retrieve the data using Javascript:<\/strong><\/p>\n<p>We have created a button \u201cGet Accounts\u201d on the html as shown below in the screenshot.<\/p>\n<p><img decoding=\"async\" class=\"aligncenter size-full wp-image-14997\" style=\"border: 1px solid #0a0a0a; padding: 1px; margin: 1px;\" src=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2019\/03\/3Retrieve-Dynamics-365-CRM-data-in-Portal-by-calling-Odata-using-JavaScript.png\" alt=\"Retrieve Dynamics 365 CRM data in Portal by calling Odata using JavaScript\" width=\"1077\" height=\"217\" \/><\/p>\n<p>On clicking the button we call the function retrieveAccount() JavaScript code shown below:<\/p>\n<p>function retreiveAccount () {<\/p>\n<p>var oDataUrl = &#8220;\/_odata\/AccountSet&#8221;;<\/p>\n<p>var response = getResponse(oDataUrl);<\/p>\n<p>var accounts = new Array();<\/p>\n<p>accounts.push([&#8220;Sr. No.&#8221;, &#8220;Name&#8221;]);<\/p>\n<p>if (response != null) {<\/p>\n<p>$.each(response, function (index, responseVal) {<\/p>\n<p>accounts.push([(index + 1), (responseVal.name.toString())]);<\/p>\n<p>});<\/p>\n<p>}<\/p>\n<p>\/\/Create a HTML Table element to show the data.<\/p>\n<p>var table = document.createElement(&#8220;TABLE&#8221;);<\/p>\n<p>table.border = &#8220;1&#8221;;<\/p>\n<p>\/\/Get the count of columns.<\/p>\n<p>var columnCount = accounts[0].length;<\/p>\n<p>\/\/Add the header row.<\/p>\n<p>var row = table.insertRow(-1);<\/p>\n<p>for (var i = 0; i &lt; columnCount; i++) {<\/p>\n<p>var headerCell = document.createElement(&#8220;TH&#8221;);<\/p>\n<p>headerCell.innerHTML = accounts[0][i];<\/p>\n<p>row.appendChild(headerCell);<\/p>\n<p>}<\/p>\n<p>\/\/Add the data rows.<\/p>\n<p>for (var i = 1; i &lt; accounts.length; i++) {<\/p>\n<p>row = table.insertRow(-1);<\/p>\n<p>for (var j = 0; j &lt; columnCount; j++) {<\/p>\n<p>var cell = row.insertCell(-1);<\/p>\n<p>cell.innerHTML = accounts[i][j];<\/p>\n<p>}<\/p>\n<p>}<\/p>\n<p>var dvTable = document.getElementById(&#8220;dvTable&#8221;);<\/p>\n<p>dvTable.innerHTML = &#8220;&#8221;;<\/p>\n<p>dvTable.appendChild(table);<\/p>\n<p>}<\/p>\n<p>function getResponse(oDataUrl) {<\/p>\n<p>var response = null;<\/p>\n<p>$.ajax({<\/p>\n<p>type: &#8220;GET&#8221;,<\/p>\n<p>url: oDataUrl,<\/p>\n<p>dataType: &#8220;json&#8221;,<\/p>\n<p>async: false<\/p>\n<p>}).done(function (json) {<\/p>\n<p>response = json.value;<\/p>\n<p>});<\/p>\n<p>return response;<\/p>\n<p>}<\/p>\n<p>Now data can be shown on the website as shown below in the screenshot:<\/p>\n<p><img decoding=\"async\" class=\"aligncenter size-full wp-image-14998\" style=\"border: 1px solid #0a0a0a; padding: 1px; margin: 1px;\" src=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2019\/03\/4Retrieve-Dynamics-365-CRM-data-in-Portal-by-calling-Odata-using-JavaScript.png\" alt=\"Retrieve Dynamics 365 CRM data in Portal by calling Odata using JavaScript\" width=\"892\" height=\"409\" \/><\/p>\n<h2><strong>Conclusion<\/strong><\/h2>\n<p>User can perform the retrieve operation by calling OData query using JavaScript<\/p>\n<h2 style=\"text-align: left;\"><div class=\"su-heading su-heading-style-default su-heading-align-center\" id=\"\" style=\"font-size:15px;margin-bottom:5px\"><div class=\"su-heading-inner\">One Pic = 1000 words! Analyze data 90% faster with visualization apps!<\/div><\/div><\/h2>\n<p style=\"text-align: left;\"><em>Get optimum visualization of Dynamics 365 CRM data with &#8211;<\/em><br \/>\n<em><strong><a href=\"https:\/\/bit.ly\/3lYvozZ\" target=\"_blank\" rel=\"noopener noreferrer\">Kanban Board<\/a> <\/strong>\u2013 Visualize Dynamics 365 CRM data in Kanban view by categorizing entity records in lanes and rows as per their status, priority, etc.<\/em><br \/>\n<em><strong><a href=\"https:\/\/bit.ly\/3lCSBaA\" target=\"_blank\" rel=\"noopener noreferrer\">Map My Relationships<\/a><\/strong> \u2013 Map My Relationships \u2013 Visualize connections and relationships between Dynamics 365 CRM entities or related records in a Mind Map view.<\/em><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Introduction When user needs to display all the record using the \u201caccount\u201d entity on the portal page then he can perform the retrieve operation by calling OData query using JavaScript. Working First we will create the entity list. On the entity list there is tab \u201cOData\u201d where we need to fill the information like \u201cEntity\u2026 <span class=\"read-more\"><a href=\"https:\/\/www.inogic.com\/blog\/2019\/03\/retrieve-dynamics-365-crm-data-in-portal-by-calling-odata-using-javascript\/\">Read More &raquo;<\/a><\/span><\/p>\n","protected":false},"author":13,"featured_media":15002,"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":[33,37],"tags":[1162,1467],"class_list":["post-14994","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-javascript","category-microsoft-portals","tag-microsoft-portal","tag-retrieve-dynamics-365-crm-data"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/posts\/14994","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=14994"}],"version-history":[{"count":0,"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/posts\/14994\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/media\/15002"}],"wp:attachment":[{"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/media?parent=14994"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/categories?post=14994"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/tags?post=14994"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}