Crm Fetchxml Activitytypecode Result Doesn't Have Enum Int Value
I have a JS project where I want to pull out the CRM Activity types, let the user select and then do another fetchxml query with the chosen activity types. I can get distinct list
Solution 1:
you could use the WebAPI (Odata) and include odata.include-annotations=OData.Community.Display.V1.FormattedValue in the header of the call using the name Prefered.
function retrieveEntity(entityName, Id, columnSet) {
var serverURL = Xrm.Page.context.getClientUrl();
var Query = entityName + "(" + Id + ")" + columnSet;
var req = new XMLHttpRequest();
req.open("GET", serverURL + "/api/data/v8.0/" + Query, true);
req.setRequestHeader("Accept", "application/json");
req.setRequestHeader("Content-Type", "application/json; charset=utf-8");
req.setRequestHeader("OData-MaxVersion", "4.0");
req.setRequestHeader("OData-Version", "4.0");
req.setRequestHeader("Prefer", "odata.include-annotations=OData.Community.Display.V1.FormattedValue");
req.onreadystatechange = function() {
if (this.readyState == 4/* complete */ ) {
req.onreadystatechange = null;
if (this.status == 200) {
vardata = JSON.parse(this.response);
if (data != null {
alert(data["_primarycontactid_value@OData.Community.Display.V1.FormattedValue"]); //for lookup text
alert(data["paymenttermscode@OData.Community.Display.V1.FormattedValue"]); //for optionset text
}
} else {
var error = JSON.parse(this.response).error;
alert(error.message);
}
}
};
req.send();
}
http://himbap.com/blog/?p=2077
Hope it helps - M.Acosta.D
Post a Comment for "Crm Fetchxml Activitytypecode Result Doesn't Have Enum Int Value"