web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Retrieve table of options of a glabal option set WEB API

(0) ShareShare
ReportReport
Posted on by

Hi,

I met some problem in retrieving my table of options, I have a customize solution with a web resource and some option set. 

I would like to retrieve from the option set, a table of option without having to add the option set into my form.

I know how to pass my parameter in my web resource to retrieve the Name of the option set (tit_continents).

But my WEB API is not doing what I would like.

Does anybody know what I am doing wrong ?

//Get client context
var context = window.parent.Xrm.Page.context;
var clientURL = context.getClientUrl();
console.log("clientURL", clientURL);
//Will contain the result of the optionSet
var tableOptions;

var req = new XMLHttpRequest
req.open ("GET", encodeURI(clientURL + "/api/data/v8.2/GlobalOptionSetDefinitions(Name='tit_continents_test')"), true);
req.setRequestHeader("Content-Type", "application/json; charset=utf-8");
req.setRequestHeader("OData-MaxVersion", "4.0");
req.setRequestHeader("OData-Version", "4.0");
req.onreadystatechange == function (){
	if (this.readyState == 4 /* complete*/ ) {
		req.onreadystatechange = null;
		if (this.status == 200) {
			tableauOptions = JSON.parse(this.responseText);
		}
		else {
			var error = JSON.parse(this.response).error;
		}
	}
};
req.send()
console.log("TableOptions", tableOptions.Options);


Thank you for your help

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    ram r Profile Picture
    on at

    Not sure what is the issue your are facing, please provide more details specific to your issue if the following doesn't help.

    If the issue is around the webapi call, refer following blog

    https://community.dynamics.com/crm/b/mscrmcustomization/archive/2016/10/18/ms-crm-2016-web-api-operations-retrieve-single-or-multiple-records#mce_temp_url#

    I have tried to retrieve an optionset and following is the input url and reponse

    https://contoso.crm.dynamics.com/api/data/v8.2/GlobalOptionSetDefinitions(Name='goal_fiscalperiod')

    Sample response is available in the following link

    http://www.jsoneditoronline.org/?id=29708d61183507b310dbc655490cced7

    Truncated response

    {
      "@odata.context":"contoso.crm.dynamics.com/.../v8.2$metadata#GlobalOptionSetDefinitions/$entity","@odata.type":"#Microsoft.Dynamics.CRM.OptionSetMetadata","Options":[
        {
          "Value":1,"Label":{
            "LocalizedLabels":[
              {
                "Label":"Quarter 1","LanguageCode":1033,"IsManaged":true,"MetadataId":"0b9bc51d-2c85-41df-aeec-6c11e0440c84","HasChanged":null
              }
            ],"UserLocalizedLabel":{
              "Label":"Quarter 1","LanguageCode":1033,"IsManaged":true,"MetadataId":"0b9bc51d-2c85-41df-aeec-6c11e0440c84","HasChanged":null
            }
    .
    .
    .
  • Community Member Profile Picture
    on at

    Es posible que no sea un optionset global y tengas que consultar la metadata en EntityDefinitions. ejm: "EntityDefinitions(LogicalName='{Entidad}')/Attributes(LogicalName='{OptionSet}')/Microsoft.Dynamics.CRM.PicklistAttributeMetadata?$select=LogicalName&$expand=GlobalOptionSet($select=Options)"

  • twaraa solutions Profile Picture
    on at

    Thanks a lot this helped me

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans