Reputation: 11
i search a solution to add a specific filter on the new lookup quickfind.
the problem is specific on the customerid lookup type, because this used the "client" types who included the account and contact on the same lookup (this is the new multi-entity lookup)
i get on this lookup account and contact, and want to filter just the contact who are from a specific account.
i try another way to change it is to change the html object but without success.
here is the html data of the specific lookup.
the lookuptypesnames and createpermissiondictionary contains account and contact, if i change the lookuptype=1 that give me anly the contact.
then i search a native way to change the customerid lookup on a specific entity (just on contact ) , dont want to used jquery function.
Upvotes: 1
Views: 4917
Reputation: 21
You should use setLookupTypes
.
Something like this:
var owner = Xrm.Page.getAttribute("ownerid").getLookupDataAttribute();
owner.setLookupTypes(["systemuser"]);
Upvotes: 1
Reputation: 1186
This is what I've done to set up the Customer lookup to show only Contact records.
function Form_OnLoad()
...
preFilterLookup();
..
}
function preFilterLookup() {
Xrm.Page.getControl("customerid").addPreSearch(addLookupFilter);
}
function addLookupFilter() {
document.getElementById("customerid_i").setAttribute("lookuptypenames", "contact:2:Contact");
document.getElementById("customerid_i").setAttribute("lookuptypes", "2");
var account = Xrm.Page.getAttribute("aux_account").getValue();
if (account != null) {
var filter = "<filter type='and'>" + "<condition attribute='parentcustomerid' operator='eq' value='" + account[0].id + "' /></filter>";
Xrm.Page.getControl("customerid").addCustomFilter(filter);
}
Upvotes: 1
Reputation: 11
if the account control is a lookup then your fetchXml should be
fetchXml = "<filter type='and'><condition attribute='parentcustumerid' operator='eq' uitype='contact' value='" + account[0].id + "' /></filter>";
Upvotes: 0