{"id":4114,"date":"2021-03-16T15:55:15","date_gmt":"2021-03-16T15:55:15","guid":{"rendered":"https:\/\/himbap.com\/blog\/?p=4114"},"modified":"2021-03-17T04:14:18","modified_gmt":"2021-03-17T04:14:18","slug":"getting-all-global-optoinset-options-using-xrm-webapi-quick-tip","status":"publish","type":"post","link":"https:\/\/himbap.com\/blog\/?p=4114","title":{"rendered":"Getting All Global Optionset options using Xrm.WebApi -{Quick Tip}"},"content":{"rendered":"<p><strong>Requirement<\/strong><br \/>\nRecently we got one requirement where we wanted to get global option set values to show it over html page, I faced one issue of not getting all the option set after changing global option set. In this post I am going to share trick how to fix it, if you have same requirement this will help you.<\/p>\n<p><strong>Details<\/strong><br \/>\nWhen we want to get global option set or option set, we can use stringmap entity. Sometime back I wrote another post to get it using old method, you can refer it <a href=\"https:\/\/himbap.com\/blog\/?p=1997\">here<\/a>.<\/p>\n<p>But let&#8217;s say we want to use Xrm.WebApi and using fetchXML, you can design your fetchXML using using tools available in XrmToolbox and can use following code:<\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\r\nvar fetchXML=&quot;YOUR FETCHXML&quot;;\r\nfetchXml = &quot;?fetchXml=&quot; + encodeURIComponent(fetchXml);\r\nXrm.WebApi.retrieveMultipleRecords(&quot;stringmap&quot;, fetchXML).then(\r\n    function success(result) {\r\n        for (var i = 0; i &lt; result.entities.length; i++) {\r\n            console.log(result.entities[i][&quot;value&quot;]);\r\n        }                    \r\n       \r\n    },\r\n    function (error) {\r\n        console.log(error.message);\r\n    }\r\n);\r\n}\r\n<\/pre>\n<p>While using this code I faced one strange issue if you will add new items to the option set and just publish global option set it won&#8217;t get all the option returned in your query result, to fix this issue you have to use Publish All option.<\/p>\n<p>Hope it will help someone!<br \/>\n<strong>Keep learning, Keep sharing !!<\/strong><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Requirement Recently we got one requirement where we wanted to get global option set values to show it over html page, I faced one issue of not getting all the option set after changing global option set. In this post I am going to share trick how to fix it, if you have same requirement this will help you. Details&#8230; <a href=\"https:\/\/himbap.com\/blog\/?p=4114\">Read more &raquo;<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[21],"tags":[874,872,873,876,875],"_links":{"self":[{"href":"https:\/\/himbap.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/4114"}],"collection":[{"href":"https:\/\/himbap.com\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/himbap.com\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/himbap.com\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/himbap.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=4114"}],"version-history":[{"count":7,"href":"https:\/\/himbap.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/4114\/revisions"}],"predecessor-version":[{"id":4121,"href":"https:\/\/himbap.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/4114\/revisions\/4121"}],"wp:attachment":[{"href":"https:\/\/himbap.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=4114"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/himbap.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=4114"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/himbap.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=4114"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}