Hi All
I want to use highlighted variable contents to query the contents of a lookup field. Please see code below:
var provinces;
window.parent.Xrm.WebApi.online.retrieveMultipleRecords("dea_province", "?$select=dea_name,dea_provinceid&$filter=dea_name eq "'" + provinces + "').then(
function success(results) {
debugger;
for (var i = 0; i < results.entities.length; i++) {
var dea_name = results.entities[i]["dea_name"];
var dea_provinceid = results.entities[i]["dea_provinceid"];
console.log(dea_name);
console.log(dea_provinceid);
//Populate lookup
var lookupValue = new Array();
lookupValue[0] = new Object();
lookupValue[0].id = dea_provinceid; // GUID of the lookup id
lookupValue[0].name = dea_name; // Name of the lookup
lookupValue[0].entityType = "dea_province"; //Entity Type of the lookup entity
window.parent.Xrm.Page.getAttribute("dea_province").setValue(lookupValue);
}
},
function(error) {
Xrm.Utility.alertDialog(error.message);
}
);
I am not sure if I am not placing the escape characters correctly. Please help.
Kind Regards
Siyabonga