Getting All Global Optionset options using Xrm.WebApi -{Quick Tip}

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.

When 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 here.

But let’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:

fetchXml = "?fetchXml=" + encodeURIComponent(fetchXml);
Xrm.WebApi.retrieveMultipleRecords("stringmap", fetchXML).then(
    function success(result) {
        for (var i = 0; i < result.entities.length; i++) {
    function (error) {

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’t get all the option returned in your query result, to fix this issue you have to use Publish All option.

Hope it will help someone!
Keep learning, Keep sharing !!

Leave a Reply

Your email address will not be published. Required fields are marked *