Whenever we have multiple entity type lookup like Customer, Regarding, Required Attendee in the form, we will get the requirement like "how to show only selected entities or hide the unwanted entities or dis-allow the user to choose them atleast?".

Over a period of time we are following different ways to achieve based on CRM versions, either supported or non-recommended unsupported way.

I have answered this SO question by referring Natraj Yegnaraman blogpost, in-fact this is a famous & frequent asked problem.

This below code will show all the entities in the lookup window but no results will come, so users cannot choose the value of account/user & proceed. They must choose a contact.

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

//remove accounts

var accountFilter = "<filter type='and'><condition attribute='accountid' operator='null' /></filter>";
//remove system users
var systemUserFilter = "<filter type='and'><condition attribute='systemuserid' operator='null' /></filter>";

Xrm
.Page.getControl('requiredattendees').addCustomFilter(contactFilter, "contact");
Xrm.Page.getControl('requiredattendees').addCustomFilter(accountFilter, "account");
Xrm.Page.getControl('requiredattendees').addCustomFilter(systemUserFilter, "systemuser");
This is ok but not a elegant solution.

From Dynamics 365 v9 onwards we got a fully functional method called setEntityTypes in both web & UCI.

formContext.getControl('your_field').setEntityTypes(['contact']);


We have an undocumented/unsupported method called setLookupTypes  until v8 (2016)

Xrm.Page.getAttribute('your_field').setLookupTypes(['contact']);