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)

Multi-Entity Subgrid

(1) ShareShare
ReportReport
Posted on by

Hey everyone,

I have a requirement to create a subgrid showing with 4 different entities included back in the results instead of showing 4 different subgrids.

I have a main entity which has 4 1:N relationships which I want included in the single subgrid. I have other subgrids using custom fetchxml however I am unsure about how to included results back to the grid from different relationships.

Thanks in advance

*This post is locked for comments

I have the same question (0)
  • wtc.nvorhees Profile Picture
    on at

    That's not possible out of the box. You would be best off implementing a custom grid in HTML / JS. There are a number of libraries out there to make the development a bit easier. React.js or http://www.sparklexrm.com/ ,come to mind. There might be some third party custom grids out there that can do this as well. 

  • Suggested answer
    C. Dennett Profile Picture
    330 on at

    You should be able to do this by linking the related entities in your XML. For example, here is the XML for the "My Activities" System View:

    <fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="true" >
      <entity name="activitypointer" >
        <attribute name="activityid" />
        <attribute name="scheduledstart" />
        <attribute name="regardingobjectid" />
        <attribute name="prioritycode" />
        <attribute name="scheduledend" />
        <attribute name="activitytypecode" />
        <attribute name="instancetypecode" />
        <attribute name="community" />
        <order attribute="scheduledend" descending="false" />
        <filter type="and" >
          <condition attribute="statecode" operator="in" >
            <value>0</value>
            <value>3</value>
          </condition>
          <condition attribute="isregularactivity" operator="eq" value="1" />
        </filter>
        <link-entity name="activityparty" from="activityid" to="activityid" alias="aa" >
          <filter type="and" >
            <condition attribute="partyid" operator="eq-userid" />
          </filter>
        </link-entity>
      </entity>
    </fetch>


    Your XML might look something like this:

    <fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="true" >
      <entity name="mainEntity" >
        <attribute name="column1" />
        <attribute name="column2" />
    <...> (more attributes) <filter type="and" > <condition attribute="filterColumn" operator="in" > <value>0</value> <value>3</value> </condition> <condition attribute="anotherFilterColumn" operator="eq" value="1" /> </filter> <link-entity name="SubEntity1" from="relatedColumn" to="relatedColumn" alias="alias" > <filter type="and" > <more filter conditions, if any> </filter> </link-entity>
    <link-entity name="SubEntity2" from="relatedColumn" to="relatedColumn" alias="alias" >
          <attribute name="subEntityColumnYouWant1" />
    <attribute name="subEntityColumnYouWant2" />
        </link-entity>
    <link-entity name="SubEntity3" from="relatedColumn" to="relatedColumn" alias="alias" >
          <attribute name="subEntityColumnYouWant1" />
        </link-entity>
    <link-entity name="SubEntity4" from="relatedColumn" to="relatedColumn" alias="alias" >
          <attribute name="subEntityColumnYouWant1" />
        </link-entity>
    </entity> </fetch>

    Hopefully this helps to guide you in the right direction. Let me know if it works for you! :)
     

  • Suggested answer
    gdas Profile Picture
    50,091 Moderator on at

    Hi Jason ,

    Out of the box its not possible. You may try with custom fetch xml.

    Are you facing any issue with custom fetch xml results.

    Try to prepare the fetchxml through advance find with alias name.Hope this helps.

    stackoverflow.com/.../show-multiple-relationship-records-in-single-view

  • Community Member Profile Picture
    on at

    Thanks Chris, this looks fairly promising! Before testing this code out, will it show the records of each linked entity on a separate row?

  • C. Dennett Profile Picture
    330 on at

    It should. The weirdness might show up in the columns though. Since not all entities will have the same columns, there will be blanks in those columns for that row. Much like when you join SQL tables, and the columns from the joined table don't exist in the base table, and you just see NULL for those columns.

    Your results should look something like:

    MainEntityColumn1    MainEntityColumn2    SubEntity1Column1    SubEntity2Column1

    <somevalue>             <somevalue>             <somevalue>              <blank>

    <somevalue>             <somevalue>             <blank>                      <somevalue>

    However, as long as your filters are solid, and your linked entities are all using the proper related columns, your records should all show up each in their own row in the subgrid. :)

  • Aric Levin - MVP Profile Picture
    30,190 Moderator on at

    Hi Jason,

    Don't think this can be done properly without replicating your entities and some custom logic.

    What you could do is create an entity with the shared fields that you want of the other four entities, and basically create plugins for create/update/delete messages on the four entities to update the combined entity.

    This is probably not the way to go.

    It would be easier to create a custom web resource. The web resource will use web api to call the four related entities, and populate the rows.

    Saying that, if the four entities are sharing data, could you possibly create the four entities as a single entity.

    Hope this helps.

  • Community Member Profile Picture
    on at

    Hey Chris, unfortunately this doesn't fit my purpose. I am needing each entity to have its own row results. For example:

    Main entity result

    Sub entity result

    sub entity 2 result

    sub entity 3 result

    etc.

  • David Jennaway Profile Picture
    14,065 on at

    Another option might be to use virtual entities. I expect you could create a virtual entity, and create a custom data provider that would query the 4 different entities and union the results

  • C. Dennett Profile Picture
    330 on at

    I'm not sure this is possible at all, let alone with XML. Unless the entities have identical columns there would be no way to render the results properly in a grid view. I would look more closely at Aric's answer above and see what options might work for you. I think that's probably going to be your best bet to get closest to what you want. :)

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