
Announcements
Hi
I'm having trouble with the following.
On Account entity have a field thats a lookup for Account i.e. a service business(account) and a lookup service personnel(contacts).
I can't work out how to filter the service peronnel(contact) by contacts that have the service business(account) as their parent.
Filtered lookup OOB won't work I don't think as it is technically a lookup to the same entity.
I can't get my head around the fetch JS to do a filtered view for this scenario.
*This post is locked for comments
I have the same question (0)Oh it can be fustrating when somethings so simple.
function servicePerson() {
// add the event handler for PreSearch Event
Xrm.Page.getControl("dsd_serviceperson").addPreSearch(addFilter);
}
function addFilter() {
var entityId, lookupFieldObject;
lookupFieldObject = Xrm.Page.data.entity.attributes.get('dsd_serviceaccount');
if (lookupFieldObject.getValue() != null) {
entityId = lookupFieldObject.getValue()[0].id;
}
if (entityId != null) {
//create a filter xml
var filter = "<filter type='and'>" +
"<condition attribute='parentcustomerid' operator='eq' value='" + entityId + "'/>" +
"</filter>";
//add filter
Xrm.Page.getControl("dsd_serviceperson").addCustomFilter(filter);
}
}