supported JavaScript on UCI Dynamics 365 Archives - Microsoft Dynamics 365 Blog http://microsoftdynamics.in/tag/supported-javascript-on-uci-dynamics-365/ Microsoft Dynamics CRM . Microsoft Power Platform Thu, 21 May 2020 15:03:31 +0000 en-US hourly 1 https://wordpress.org/?v=6.6.1 https://i0.wp.com/microsoftdynamics.in/wp-content/uploads/2020/04/cropped-Microsoftdynamics365-blogs.png?fit=32%2C32 supported JavaScript on UCI Dynamics 365 Archives - Microsoft Dynamics 365 Blog http://microsoftdynamics.in/tag/supported-javascript-on-uci-dynamics-365/ 32 32 176351444 Restricting the Multi Entity lookup field Customer or Regarding Party list Entities from Email TO, CC, From – supported JavaScript on UCI Dynamics 365 http://microsoftdynamics.in/2020/05/21/restricting-the-multi-entity-lookup-field-customer-or-regarding-party-list-entities-from-email-to-cc-from-supported-javascript-on-uci-dynamics-365/ Thu, 21 May 2020 15:01:59 +0000 http://microsoftdynamics.in/?p=3034 We got into a scenario were customer don’t want Email “To” field to have all entity and restrict “To” field with contact, Lead and User Entity Only There was the same scenario for the customer which occurred last year and below was the code written fo that but the same javascript didn’t work multiple entity ...

The post Restricting the Multi Entity lookup field Customer or Regarding Party list Entities from Email TO, CC, From – supported JavaScript on UCI Dynamics 365 appeared first on Microsoft Dynamics 365 Blog.

]]>
We got into a scenario were customer don’t want Email “To” field to have all entity and restrict “To” field with contact, Lead and User Entity Only

There was the same scenario for the customer which occurred last year and below was the code written fo that but the same javascript didn’t work multiple entity  lookup for more than 2 entities

The old way of filtering Lookup for customer field JavaScript 

function defaultlookfor(){
Xrm.Page.getControl(“parentcustomerid”).addPreSearch(addFilter);
}

function addFilter(){
var emailToFilterAcc = “<filter type=’and’><condition attribute=’accountid’ operator=’null’ /></filter>”;
Xrm.Page.getControl(“to”).addCustomFilter(emailToFilter , “account”);

}

 

For Multi entity lookup like Email entity TO, FROM, CC field or regarding field Below OOB JAVASCRIPT Works perfectly

 

JavaScript (9.x) – Supported

var lookupTO = Xrm.Page.getControl('to');
//check if multiple type dropdowns enabled for this lookup
if (lookupTo.getEntityTypes().length > 1) {
    lookupTO.setEntityTypes(['contact','lead','systemuser']);
}

JavaScript (8.x) – Unsupported

var lookupTO = Xrm.Page.getAttribute('to');
//check if multiple type dropdowns enabled for this lookup   
if (lookupTO.getLookupTypes().length > 1
&& !lookupTO.getIsPartyList()) {
lookup.setLookupTypes(['contact']);
}

 

We can Set above snippet onLoad of form ,
Remember in  FormContext.getControl(arg).setEntityTypes([entityLogicalNames]); , entityLogicalNames is of array type and can have multple entities defined with comma.

Parameter entityLogicalNames

TABLE 1
Name Type Required Description
entityLogicalNames Array of String Yes Specify the logical name of the entities allowed in the lookup control.

 

Below is the lookup screenshot after restricting email “TO” field entities

function onFormRestrictEntity(executionContext) {
var formContext = executionContext.getFormContext();
varlookupTO = formContext.getControl('to');
if (lookupTO.getEntityTypes().length > 1) {
lookup.setEntityTypes(['contact','lead','systemuser','queue']);
}

 

 

Reference : https://docs.microsoft.com/en-us/powerapps/developer/model-driven-apps/clientapi/reference/controls/setEntityTypes

The post Restricting the Multi Entity lookup field Customer or Regarding Party list Entities from Email TO, CC, From – supported JavaScript on UCI Dynamics 365 appeared first on Microsoft Dynamics 365 Blog.

]]>
3034