Hi All,
I am trying to use the below code to get current value of enviornment variable but its always giving the null value. I am passing my schema name as well which is "new_url". Can you please see what mistakes I am making?
getEnvironmentVariable : function (formContext, schemaName) {
varreq = newXMLHttpRequest();
req.open("GET", Xrm.Utility.getGlobalContext().getClientUrl() + "/api/data/v9.2/environmentvariabledefinitions?$expand=environmentvariabledefinition_environmentvariablevalue($select=schemaname,value)&$filter=schemaname eq '" + schemaName+ "'", true);
req.setRequestHeader("OData-MaxVersion", "4.0");
req.setRequestHeader("OData-Version", "4.0");
req.setRequestHeader("Content-Type", "application/json; charset=utf-8");
req.setRequestHeader("Accept", "application/json");
req.setRequestHeader("Prefer", "odata.include-annotations=*");
req.onreadystatechange = function () {
if (this.readyState === 4) {
req.onreadystatechange = null;
if (this.status === 200) {
varresults = JSON.parse(this.response);
console.log(results);
for (vari = 0; i< results.value.length; i++) {
varresult = results.value[i];
// Columns
varenvironmentvariabledefinitionid = result["environmentvariabledefinitionid"]; // Guid
// One To Many Relationships
for (varj = 0; j< result.environmentvariabledefinition_environmentvariablevalue.length; j++) {
varenvironmentvariabledefinition_environmentvariablevalue_schemaname = result.environmentvariabledefinition_environmentvariablevalue[j]["schemaname"]; // Text
varenvironmentvariabledefinition_environmentvariablevalue_value = result.environmentvariabledefinition_environmentvariablevalue[j]["value"]; // Multiline Text
}
}
} else {
console.log(this.responseText);
}
}
};
req.send();
},