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

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

exclude other entities from "to/cc/bcc" partylist field other than contact

(0) ShareShare
ReportReport
Posted on by 340

Hi Experts, 

I have requirement like when email form loads and when i try to select to/cc/bcc then i should see only contact recipient not others like accounts , users , leads , ...... .

Please advise how i can get this done ?

I'm planning to do it through js and followed this link but getting syntax error.

This is urgent , Thank you in advance 

Regards, Alok

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Arun Vinoth Profile Picture
    11,615 Moderator on at

    Based on your CRM version there are different ways to achieve it.

        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");

    9.x documented & supported way:

    Xrm.Page.getControl('your_field').setEntityTypes(['contact']);

    https://stackoverflow.com/a/50837293/7920473 

  • Alok Sharma Profile Picture
    340 on at

    Hi Arun Vinoth,

    I tried above steps provided by you in my email form but still I'm able to select accounts , users ....

    I tried below :

    function AppendFilterSearch() {
      
      var FormType = Xrm.Page.ui.getFormType();
      if(FormType==1 && FormType==2){
        Xrm.Page.getControl("requiredattendees").addPreSearch(function () {
            AddPreSearch();
        });
    }}
     
    function AddPreSearch() {
        var contactFilter = "<filter type='and'><condition attribute='contactid' operarequiredattendeesr='not-null' /></filter>";
    	//remove accountt
        var accountFilter = "<filter type='and'><condition attribute='accountid' operarequiredattendeesr='null' /></filter>";
        //remove system users
        var systemUserFilter = "<filter type='and'><condition attribute='systemuserid' operarequiredattendeesr='null' /></filter>";
        //remove lead
        var leadFilter = "<filter type='and'><condition attribute='leadid' operarequiredattendeesr='null' /></filter>";
        //remove facility
        var facilityFilter = "<filter type='and'><condition attribute='equipmentid' operarequiredattendeesr='null' /></filter>";
    	// remove entitlement
    	var entitlementFilter = "<filter type='and'><condition attribute='entitlementid' operarequiredattendeesr='null' /></filter>";
    
    	
     
        Xrm.Page.getControl("requiredattendees").addCusrequiredattendeesmFilter(contactFilter, "contact");
        Xrm.Page.getControl("requiredattendees").addCusrequiredattendeesmFilter(accountFilter, "account");
        Xrm.Page.getControl("requiredattendees").addCusrequiredattendeesmFilter(systemUserFilter, "systemuser");
        Xrm.Page.getControl("requiredattendees").addCusrequiredattendeesmFilter(leadFilter, "lead");
        Xrm.Page.getControl("requiredattendees").addCusrequiredattendeesmFilter(facilityFilter, "equipment");
    	Xrm.Page.getControl("requiredattendees").addCusrequiredattendeesmFilter(entitlementFilter, "entitlement");
    }


    Please let me know if I'm making any mistake

  • Verified answer
    RaviKashyap Profile Picture
    55,410 Moderator on at

    Hi,

    Try changing "operarequiredattendeesr" to "operator"  and a"ddCusrequiredattendeesmFilter" to "addCustomFilter" to in your code and see if this works.

    Hope this helps.

  • Alok Sharma Profile Picture
    340 on at

    Hi Ravi, 

    I tried same as you suggested but still no outcome. :(

    function AppendFilterSearch() {
      
      var FormType = Xrm.Page.ui.getFormType();
      if(FormType==1 && FormType==2){
        Xrm.Page.getControl("to").addPreSearch(function () {
            AddPreSearch();
        });
    }}
     
    function AddPreSearch() {
        var contactFilter = "<filter type='and'><condition attribute='contactid' operator='not-null' /></filter>";
    	//remove accountt
        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>";
        //remove lead
        var leadFilter = "<filter type='and'><condition attribute='leadid' operator='null' /></filter>";
        //remove facility
        var facilityFilter = "<filter type='and'><condition attribute='equipmentid' operator='null' /></filter>";
    	// remove entitlement
    	var entitlementFilter = "<filter type='and'><condition attribute='entitlementid' operator='null' /></filter>";
    
    	
     
        Xrm.Page.getControl("to").addCustomFilter(contactFilter, "contact");
        Xrm.Page.getControl("to").addCustomFilter(accountFilter, "account");
        Xrm.Page.getControl("to").addCustomFilter(systemUserFilter, "systemuser");
        Xrm.Page.getControl("to").addCustomFilter(leadFilter, "lead");
        Xrm.Page.getControl("to").addCustomFilter(facilityFilter, "equipment");
    	Xrm.Page.getControl("to").addCustomFilter(entitlementFilter, "entitlement");
    }
  • Verified answer
    RaviKashyap Profile Picture
    55,410 Moderator on at

    Hi

    i think its the formtype check due to which the code is not executing. could you remove that check and try again. Dont forget to publish customization and try on a new browser window.

  • Verified answer
    Alok Sharma Profile Picture
    340 on at

    Hi Ravi,

    Thank you for notifying that, checking formtype was good but in that i was checking formtype with and (&&) condition which is not possible to true so now i have made it or (||) condition and it is working now.

    Thanks and Regards, Alok

  • Verified answer
    Alok Sharma Profile Picture
    340 on at

    One more approach worked for me :

    if(FormType==1 || FormType==2)
      {
        var controlTo = Xrm.Page.getControl("to");
    
        controlTo.getAttribute().setLookupTypes(["contact"]);
    	
    	
    }


  • Suggested answer
    RaviKashyap Profile Picture
    55,410 Moderator on at

    Yes, thats the new method availabl in V9. For earlier version, you need to use addcustomfilter :)

  • Suggested answer
    Arun Vinoth Profile Picture
    11,615 Moderator on at

    Great to hear. setLookupTypes is undocumented/unsupported but setEntityTypes is documented/supported in v9.

    I explained all this in original initial answer & SO link. Feel free to mark them as answer if it helped you.

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans