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

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Microsoft Dynamics 365 | Integration, Dataverse...
Answered

Filter customer lookup to show accounts only on Contact

(0) ShareShare
ReportReport
Posted on by

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

I have the same question (0)
  • meelamri Profile Picture
    13,218 User Group Leader on at

    Hi,

    Can you please share the error message?

  • NielsSL Profile Picture
    on at

    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

  • Verified answer
    meelamri Profile Picture
    13,218 User Group Leader on at

    Hi, 

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

    pastedimage1629102064236v1.png

  • NielsSL Profile Picture
    on at

    That did the job.

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

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the March Top 10 Community Leaders

These are the community rock stars!

Leaderboard > Microsoft Dynamics 365 | Integration, Dataverse, and general topics

#1
11manish Profile Picture

11manish 172

#2
ManoVerse Profile Picture

ManoVerse 58 Super User 2026 Season 1

#3
Niki Patel Profile Picture

Niki Patel 42

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans