web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Restrict the 'Customer Lookup' to a filtered set of customers in the case entity

(0) ShareShare
ReportReport
Posted on by 115

Hi, 

I am trying to limit the customers that are displayed in the 'Customer' lookup in the case entity. I have already restricted it to Accounts only and removed the contacts from this field, but I would now like it to just show Accounts that have a relationship type as 'Customer' (from the account entity). 

Is anyone aware of if and how this could be achieved? I'm not a coder, so I am unable to write any scripts. 

Appreciate any suggestions and help that can be offered. 

Cheers, Will 

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Rawish Kumar Profile Picture
    13,758 on at

    Hi,

    You can go to Customizations > customize the system > Entites > account > Views > Account lookup view and add the condition as relationship type =customer.

  • Suggested answer
    StefanS365 Profile Picture
    3,575 Most Valuable Professional on at

    Hi Will,

    You should add a view to the Account entity where you filter the accounts based on the existing relationship type as 'Customer'.

    Then you should set this as fixed view in the lookup on the Case form, and let users not be able to change the view of the lookup.

  • Suggested answer
    Rawish Kumar Profile Picture
    13,758 on at
  • Steady Profile Picture
    115 on at

    Thanks Stefan, I've done the first bit of this, but the Customer filed in the case entity (customerid) does not have the option to apply a filer in the field properties. Other lookups, such as Contact, do have this option. Am I missing something?

  • Suggested answer
    gdas Profile Picture
    50,091 Moderator on at

    Hi Will,

    You will not get customerid field in the condition of the lookup view. You can try with different field or you have to write code in this case.

  • StefanS365 Profile Picture
    3,575 Most Valuable Professional on at

    Goutam is right about this restriction, but you could add a view to the Account entity so users are able to select that in from the lookup to get the right selection of Customers.

  • Steady Profile Picture
    115 on at

    Thanks Goutam and Stefan. I'm happy to use some code and I suspect I need some in the events section of the field properties, but I have no idea where to start writing it and I just don't understand it. If someone could prepare it for me and tell me where to put it, I'd be really appreciative (but that's a big ask).

  • Suggested answer
    gdas Profile Picture
    50,091 Moderator on at

    Hi Will,

    You can have a look below reference -

    www.powerobjects.com/.../restrict-customer-lookup-to-accounts-or-contacts-in-dynamics-crm

  • Steady Profile Picture
    115 on at

    Hi Goutam,

    So this is the cost I have running which removes the contact lookup and just leaves the account - and this works fine.

    -------------------------------------------------------------------

    function defaultcustomer(){

      Xrm.Page.getControl("customerid").addPreSearch(addFilter);

    }

    function addFilter()

    {

      var customerAccountFilter = "<filter type='and'><condition attribute='contactid' operator='null' /></filter>";

    Xrm.Page.getControl("customerid").addCustomFilter(customerAccountFilter, "contact");

    -------------------------------------------------------------------

    What I need to do now is add an additional filter to only show accounts with a Relationship Type (CustomerTypeCode) equal to 'Customer' (Value of 3 in the option set). I've tried to add it in here but I just get errors. Can you help?

  • Suggested answer
    gdas Profile Picture
    50,091 Moderator on at

    Try with this -

    function defaultcustomer() {
        Xrm.Page.getControl("customerid").addPreSearch(addFilter);
    }
    
    function addFilter() { 
        var customerAccountFilter = "<filter type='and'><condition attribute='customertypecode' operator='eq' value='3' /></filter>";
        Xrm.Page.getControl("customerid").addCustomFilter(customerAccountFilter, "account");
    }


Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans