crm2013 - how to filter a client lookup on a specific entity

4.8k views Asked by At

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.

3

There are 3 answers

5
user3046705 On

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>";

0
Jorge On

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);
}
0
Serjanya On

You should use setLookupTypes.

Something like this:

 var owner = Xrm.Page.getAttribute("ownerid").getLookupDataAttribute();        
 owner.setLookupTypes(["systemuser"]);