Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)

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

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

  • Suggested answer
    Arun Vinoth Profile Picture
    Arun Vinoth 11,613 on at
    RE: exclude other entities from "to/cc/bcc" partylist field other than contact

    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.

  • Suggested answer
    RaviKashyap Profile Picture
    RaviKashyap 55,410 on at
    RE: exclude other entities from "to/cc/bcc" partylist field other than contact

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

  • Verified answer
    Alok Sharma Profile Picture
    Alok Sharma 340 on at
    RE: exclude other entities from "to/cc/bcc" partylist field other than contact

    One more approach worked for me :

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


  • Verified answer
    Alok Sharma Profile Picture
    Alok Sharma 340 on at
    RE: exclude other entities from "to/cc/bcc" partylist field other than contact

    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
    RaviKashyap Profile Picture
    RaviKashyap 55,410 on at
    RE: exclude other entities from "to/cc/bcc" partylist field other than contact

    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.

  • Alok Sharma Profile Picture
    Alok Sharma 340 on at
    RE: exclude other entities from "to/cc/bcc" partylist field other than contact

    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
    RaviKashyap 55,410 on at
    RE: exclude other entities from "to/cc/bcc" partylist field other than contact

    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
    Alok Sharma 340 on at
    RE: exclude other entities from "to/cc/bcc" partylist field other than contact

    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

  • Suggested answer
    Arun Vinoth Profile Picture
    Arun Vinoth 11,613 on at
    RE: exclude other entities from "to/cc/bcc" partylist field other than contact

    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 

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,214 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans