I have a field dummy_inspector that has the customer type.
When a field dummy_inspector is from type account, then a grid can show another inspectors. In a lookup I want to filter on all those inspectors.
Actually the customerAddressFilter would be this:
var customerAddressFilter = "<filter type='or'>
<condition attribute='dummy_customer' operator='eq' value='{39D2DD83-835F-E911-B818-0050569C84C7}' />
<condition attribute='dummy_customer' operator='eq' value='{C0379546-835F-E911-B818-0050569C84C7}' />
</filter>";
Is this possible? It looks like only the first condition is executed.
I have written the following JavaScript to accomplish this
if (FormContext.getAttribute("dummy_inspector").getValue() != null) {
var inspectorId = FormContext.getAttribute("dummy_inspector").getValue()[0].id;
var inspectorType = FormContext.getAttribute("dummy_inspector").getValue()[0].entityType;
var condition = "";
if (inspectorType.toLowerCase() == "account") {
// Get accountid(s) from inspection sites
var inspectionsitesGrid = FormContext.getControl("listInspectionSites").getGrid();
var inspectionsitesRows = inspectionsitesGrid.getRows();
var rowCount = inspectionsitesGrid.getTotalRecordCount();
for (var i = 0; i < rowCount; i++) {
var rowEntity = inspectionsitesRows.get(i).getData().getEntity();
condition += "<condition attribute='dummy_customer' operator='eq' value='" + rowEntity.getKey() + "' />";
}
}
var lookupControl = FormContext.getControl("dummy_inspectionlocation");
if (lookupControl != null) {
var customerAddressFilter = "<filter type='or'><condition attribute='dummy_customer' operator='eq' value='" + inspectorId + "' />" + condition + "</filter>";
lookupControl.addPreSearch(function () { lookupControl.addCustomFilter(customerAddressFilter); });
}
}
*This post is locked for comments