Has anyone successfully been able to query GlobalOptionSetDefinitions in JavaScript or TypeScript using the Xrm client API? Tried the regular Xrm.WebApi.retrieveRecord, Xrm.WebApi.retrieveMultiple and also with Xrm.WebApi.online.execute but no success. I know we can use XMLHttpRequest but was hoping we would be able to achieve with the out-of-the-box libraries...
According to the OData metadata, GlobalOptionSetDefinitions an entity and is queryable. For example:
https://env.crmN.dynamics.com/api/data/v9.1/GlobalOptionSetDefinitions(Name='fieldname')?$select=Name
{
"@odata.context": "https://env.crmN.dynamics.com/api/data/v9.0/$metadata#GlobalOptionSetDefinitions/Microsoft.Dynamics.CRM.OptionSetMetadata(Name)/$entity",
"@odata.type": "#Microsoft.Dynamics.CRM.OptionSetMetadata",
"Name": "fieldname",
"MetadataId": "a267ef1d-3e96-ea11-a812-000d3a797005"
}
Here's the error with Xrm.WebApi.online.execute. There used to be a retrieveMultiple operationName option but seems gone now.
var Sdk = window.Sdk || {};
Sdk.RetrieveRequest = function (entityReference) {
this.entityReference = entityReference;
};
Sdk.RetrieveRequest.prototype.getMetadata = function () {
return {
boundParameter: null,
parameterTypes: {},
operationType: 2,
operationName: "Retrieve",
};
};
var entityReference = {
entityType: "GlobalOptionSetDefinitions",
id: "a267ef1d-3e96-ea11-a812-000d3a797005"
};
var retrieveRequest = new Sdk.RetrieveRequest(entityReference);
return Xrm.WebApi.online.execute(retrieveRequest).then(
function (result) {}, function (error) {}
);
error code 2147746581
An error has occurred. Try this action again. If the problem continues, check the Microsoft Dynamics 365 Community for solutions or contact your organization's Microsoft Dynamics 365 Administrator. Finally, you can contact Microsoft Support.
Here are the errors with retrieveRecord and retrieveMultipleRecords (same with plural or singular entity name)
Xrm.WebApi.retrieveRecord("GlobalOptionSetDefinitions", "a267ef1d-3e96-ea11-a812-000d3a797005")
Xrm.WebApi.retrieveMultipleRecords("GlobalOptionSetDefinitions", "?$select=*&$filter=Name eq 'xyz'")
errorCode: 2147868684
message: "The entity "GlobalOptionSetDefinitions" cannot be found. Specify a valid query, and try again."
code: 2147868684
Thanks!