1

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.

b3ni
  • 11
  • 1
  • 3

3 Answers3

1

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);
}
Jorge
  • 1,178
  • 2
  • 13
  • 33
1

You should use setLookupTypes.

Something like this:

 var owner = Xrm.Page.getAttribute("ownerid").getLookupDataAttribute();        
 owner.setLookupTypes(["systemuser"]); 
Serjanya
  • 21
  • 3
0

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

user3046705
  • 11
  • 1
  • 2
  • thks for your answerd but isn't the real problem the addpresearch dont launch the function to add the filter. – b3ni Dec 05 '13 at 15:19
  • In the addLookupFilter function you cache the value of the account and if this value isn't null you filter the accounts Lookup with the cached value. Perhaps the cached value of account is null so that's the reason the addCustomFilter function isn't launched. – user3046705 Dec 06 '13 at 08:14
  • i find the way to filter the lookup! the same filter for the search windows of lookup work for the new frame. but my problem is to filter on the customerid lookup just the contact without the account. – b3ni Dec 06 '13 at 09:59
  • on the html object i change the lookuptypes=1 -> just contact and all work but i dont want to used jquery to modify thr html obejct i prefer a native way to filter the customerid just on contact entity. – b3ni Dec 06 '13 at 10:29
  • I misunderstood then.The addCustomFilter takes as an optional second argument the name of the entity to filter in case there are more than one in the lookup.Try to pass "contact" or "Contact". – user3046705 Dec 06 '13 at 11:00