locked
How to set CustomView to lookup of m:m relationship in CRM 2011 RRS feed

  • Question

  • Hi,

    I want to set a Custom View to my Lookup to which it has many to many relationship.

    In my case,

    There is a Custom Entity,

    on this custom Entity one 'Contact' Lookup is there, one 'Account' Subgrid is there.

    Both 'Contact' and 'Account' have M:M relationship with this custom Entity.

    Now, i have done a part to fetch the Contacts

    which have ParentCustomerId as this Grid Account's Primary Contact.

    But i want to fetch all such Contacts which have M:M relationship with that subgrid's Account.

    I got the Account id from grid.

    But i am not able to understand what fetchXML would come here.

    Please help.


    Tuesday, August 6, 2013 11:13 AM

Answers

  • Hi,

    You can use the advance find to construct the Fetch query.

    in case of M:M relationship you will have to link Contact with Intersect table and Intersect table with Account and specify the condition in of account Id.

    <entity name="contact">
         <attribute name="fullname" /> 
         <attribute name="contactid" />
         <link-entity name="Intersect Entity" from="contactid" to="contactid" visible="false" intersect="true">
           <link-entity name="account" from="accountid" to="accountid" alias="aa">
             <filter type="and">
               <condition attribute="accountid" operator="eq"  value="GUID Found" />
             </filter>
           </link-entity>
         </link-entity>

    Hope this helps!

    Thanks!

    Kalim Khan

    • Marked as answer by DynamicsCRM31 Monday, August 12, 2013 6:10 AM
    Sunday, August 11, 2013 8:24 AM

All replies

  • is there anyone who have done this type of customization ?
    Tuesday, August 6, 2013 1:16 PM
  • Hi,

    You can use the advance find to construct the Fetch query.

    in case of M:M relationship you will have to link Contact with Intersect table and Intersect table with Account and specify the condition in of account Id.

    <entity name="contact">
         <attribute name="fullname" /> 
         <attribute name="contactid" />
         <link-entity name="Intersect Entity" from="contactid" to="contactid" visible="false" intersect="true">
           <link-entity name="account" from="accountid" to="accountid" alias="aa">
             <filter type="and">
               <condition attribute="accountid" operator="eq"  value="GUID Found" />
             </filter>
           </link-entity>
         </link-entity>

    Hope this helps!

    Thanks!

    Kalim Khan

    • Marked as answer by DynamicsCRM31 Monday, August 12, 2013 6:10 AM
    Sunday, August 11, 2013 8:24 AM