Set Default Entity On MSCRM D365 Entity Lookup Type Field.
Views (1258)
Sometimes we have a problem for filtering only specific entity type on the lookup for collection of an entity. We write custom js code for the restrict specific entity on entity lookup.
Scenario-1: Filter only contacts entity on "to" field on the email form.curently "to" field as Parti-List type. This field contains "Account", "Contact","Entitlement","Facility/Equipment","Knowledge Article","Lead","Queue","User".we set only contact as a default filter using below js code.
1.Insial level show Email Form-
function SetDefaultView() {
var customerControl = Xrm.Page.getControl("to");
// Check if multiple type dropdowns enabled for this lookup
if (customerControl.getEntityTypes().length > 1) {
// Set entity type to contact
customerControl.setEntityTypes(['contact']);
}
}
2) this code is called on form load.
3) After applying this code on form load we validate ToThis code.
4) This code also works on UCI Interface.
You can feel free to ask any query regarding this blog.
Sumit Verma
Sr. Dynamic CRM Developer

Like
Report
*This post is locked for comments