I'm using a Xrm.Utility.lookupObjects(lookupOptions)-function on a incident-form. Everything works fine, but the filter doesn't work. You should only see the hardware of the customer which belongs to the incident.
I'm new to xml, so can some help me?
The code is:
var hardware =[];
function addhardware() {
var lookupOptions = {
defaultEntityType: "new_hardware",
entityTypes: ["new_hardware"],
allowMultiSelect: true
};
var incidentcustomer= Xrm.Page.data.entity.getId();
if(Xrm.Internal.isUci()){
lookupOptions.filters = [{
filterXml: "<filter='and'><condition attribute='new_customer' operator='eq' value=' "+incidentcustomer+" ' /></filter>",
entityLogicalName: "new_hardware"
}];
}
else{
lookupOptions.filters = ["%3Cfilter%20type%3D%22and%22%3E%3Ccondition%20attribute%3D%22new_customer%22%20operator%3D%22eq%22%20value%3D%22"+incidentcustomer+"%22%20%2F%3E%3C%2Ffilter%3E"];
lookupOptions.customFilterTypes = ["new_hardware"];
}
Xrm.Utility.lookupObjects(lookupOptions)
.then(function (result) {
var text;
for (var i = 0; i < result.length; i++) {
hardware[i]= new Object();
hardware[i].id=result[i].id;
hardware[i].name=result[i].name;
hardware[i].entityType="new_hardware"
}
text=hardware[0].name;
for(var i =1; i < hardware.length; i++) {
text = text +", " + hardware[i].name;
}
Xrm.Page.getAttribute("new_list").setValue(text);
})
.fail(function (error) {});
}
The variable hardware is used for another function.