I am using following code snippet to restrict Customer lookup on Order form to populate 'Contacts' automatically, it is working fine in CRM2016 but in D365 it automatically populate 'Accounts'.
Any suggestion to make customer lookup to show 'Contacts' automatically.
function defaultcustomer(){ Xrm.Page.getControl("customerid").addPreSearch(addFilter); } function addFilter() { var customerAccountFilter = "<filter type='and'><condition attribute='accountid' operator='null' /></filter>"; Xrm.Page.getControl("customerid").addCustomFilter(customerAccountFilter, "account"); }
*This post is locked for comments
Hi,
in my case i had to restrict to accounts.. the filter is working
Is there any way can restrict the "new" button opens only to new account entity form.. default its opening new contact form
Thank you Jon!
Just in case anyone else has my issue, I was trying to build a filter on the regardingobjectid field in an activity entity to return just accounts.
I followed the steps you can find for the customerid field that means you have to exclude entity by entity.
Jon's positive filter is much easier.
Donal
Since you are calling addPreSearch ,you should call defaultcustomer on Load .It will register PreSearch and whenever you click on lookup it will apply your Custom Filter.
I would call this onload to restrict the lookup to contacts only
At which event this will fire? on-change, onload?
This should do the trick
function defaultcustomer() { Xrm.Page.getControl("customerid").getAttribute().setLookupTypes(["contact"]); }
Mohamed Amine Mahmoudi
83
Super User 2025 Season 1
Community Member
52
Victor Onyebuchi
6