Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics 365 | Integration, Dataverse...
Answered

Filter customer lookup to show accounts only on Contact

Posted on by 87

Hi, 

I have found this blog post on to hide the contact section in the customer lookup, to only show accounts using the JavaScript below. 

pastedimage1629097455090v1.png

However, I am a rookie dealing with JavaScript, so I am looking for some help to apply it. 

I have created a JS Web Resource with the above code and added the library to my contact form. However, I get an error after I have configured the OnLoad event. 

Can anyone help/show me how it should be configured on the form? 

BR,
Niels

  • NielsSL Profile Picture
    NielsSL 87 on at
    RE: Filter customer lookup to show accounts only on Contact

    That did the job.

    Thanks for the swift help, Mehdi. It is very much appreciated!

  • Verified answer
    meelamri Profile Picture
    meelamri 13,204 User Group Leader on at
    RE: Filter customer lookup to show accounts only on Contact

    Hi, 

    You need to call Hello.contact.Form_Onload function. Please refer to the image below: 

    pastedimage1629102064236v1.png

  • NielsSL Profile Picture
    NielsSL 87 on at
    RE: Filter customer lookup to show accounts only on Contact

    Hi Mehdi, 

    I used the code from the website, where I replaced "Thrives" with "Hello". I typed the code, as it wasn't possible to copy it from the site - so I am hoping there are not typos.

    if (typeof (Hello) === "undefined") { Hello = {}; }
    
    Hello.contact = {
    	
    	Form_Onload: function(executionContext) {
    		Hello.contact.formContext = executionContext.getFormContext();
    		Hello.contact.FilterParentCustomerField();
    	},
    	
    	FilterParentCustomerField: function() {
    		Hello.contact.formContext.getControl("parentcustomerid").setEntityTypes(["account"]);
    	}
    };

    However, the error message I get depends on what I enter under Function - so that is probably where I need help. 

    I am not sure what the name of the function I am calling. I have tried Hello.contact, Hello.contact.FilterParentCustomerField, FilterParentCustomerField. 

    pastedimage1629100998919v1.png

    pastedimage1629101238238v2.png

  • meelamri Profile Picture
    meelamri 13,204 User Group Leader on at
    RE: Filter customer lookup to show accounts only on Contact

    Hi,

    Can you please share the error message?

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,214 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans