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 :
Service | Customer Service, Contact Center, Fie...
Answered

See all related Records from all Child Accounts (1:N from Account to CustomEntity) in Dynamics and Portal

(0) ShareShare
ReportReport
Posted on by

I have a custom entity, connected to Account. (1:N from Account to custom entity). My custom entity has a lookup field "account" and this field is mandatory. On the account form i have a tab with a subgrid from my custom entity to list all related records.

Now i have a new condition: I must see all records from my custom-entity of the Account and Child-Account. In the subgrid option i have "Only Related Records" option active, but the child records are not listed on the view. How i can see on the Parent Account all custom records from all child accounts. Is there are OOB way, or only with custom JS? 

Second Question: I have the same problem on my dynamics 365 portal. I have there "My Account" where the Portal-User can see/edit there own company and child companys (here its work to see all child company). On a second page i have my custom-entity where the Portal-User can add new records an see there existing records. But the same "issue", the Portal-User can add a new record for a Child-Company, but on the List he see only records from parent (master) account.

I have the same question (0)
  • Pankaj Gogoi Profile Picture
    3,177 on at

    Hello,

    Here is what I understood, you are trying to display the related custom entity record and the child records of the account in a sub-grid. Few suggestions

    1. Maybe create a separate sub grid.

    2. Associate the custom entity with the child accounts and use roll up view to display the records.

    www.inogic.com/.../

    3. You may try the retrieve multiple plugin to combined the records and display it in a view

    docs.microsoft.com/.../microsoft.xrm.sdk.iorganizationservice.retrievemultiple

    Hope this helps

  • Dy365Fan Profile Picture
    on at

    It seems that the solution from https://www.inogic.com/ only work with "activities".

    An example to understand my problem better - Lets call my custom entity "special orders".

    Account A has 3 Child Accounts (B C and D)

    Accont A has 5 records on "special orders"

    Account D has 2 records on "special orders"

    Now i will see all "special orders" from Account A and all "special orders" from Account D on the subgrid. The subgrid should show 7 records. I Hope it is clear now :)

  • Pankaj Gogoi Profile Picture
    3,177 on at

    Okay, so you are saying for Account A, it loads the 5 Special Orders and the child Account D but not the 2 special orders of D.

  • Dy365Fan Profile Picture
    on at

    check my edit - I hope is clear now :)

  • Pankaj Gogoi Profile Picture
    3,177 on at

    Without writing custom code, I can suggest you have two relationship, one with the Account and another with the Parent Account on Serial Number. Create another field in Serial Number as Parent Account and populate this field using an workflow. In related entity of Account form, it will display the Serial Number entity, one with the parent Account relationship and one with the Account relationship.

    3122.Untitled.png

    I would also suggest to try using retrieve multiple plugin

    Hope this helps.

  • Verified answer
    LeoAlt Profile Picture
    16,331 Moderator on at

    Hi Dy365Fan,

     

    You mean that you can see all custom records related to accounts and child-accounts on account form. This is a question about Deep queries for subgrids.

    Rollup views only allows users to view activities and it only for some specify entity like Opportunity, Quote, Order, Invoice, Case and Contract.

    Unfortunately, you can't use OOB to achieve it,

    You need some JavaScript to apply custom FetchXml to a subgrid.

    You can refer following:

     blogs.msdn.microsoft.com/.../deep-queries-for-subgrids

    medium.com/.../dynamically-set-fetchxml-to-subgrid-on-dynamics-365-v9-uci-a4a531200e73

    medium.com/.../nice-post-50eb2eddcc3c

    And there is another way for you, you could create a new lookup field on your custom entity form called "parent account" to store its related account's parent account. And then create a FLOW or custom console app with C# to set the correct account value to this "parent account" field, and then you will be able to roll up all the childs' subgrid records on parent account form.

    Best Regards,

    Leo

  • Dy365Fan Profile Picture
    on at

    Hi Leo

    Deep queries with JS is a way, but honestly i will avoid JS. Not because i have a problem to code with JS (we use already JS for some functions), it is because after every update i have to check every JS-Code it is still running.

    One of the links you sendet me is from 2012, and the guide from "medium.com" are nice, but you can see the problem i describe above (after update the JS-Code not worked anymore). Many "example codes" you find online are deprecated or only works for dynamics v5-8.

    Your second solution worked for me (Thx for the simple trick :)). I created a the "parent account" lookup-field on my custom-entity. Then i created a workflow that runs when record is created and fill the "parent account" with the parent account from related account. When the related account doesn't have a parent account, then the workflow fill in "parent account" the related account. On the new subgrid by the parent account i can see now all records from all child accounts and the records from parent account.

    But with the new "subgrid" i doesn't see records on the child account, because the new subgrid shows all records from parent account... I need 2 subgrid: One for parent accounts, and one for child accounts. Because on the child account i will only see the child. And here i need JS :P With custom JS-Code i show subgrid 1 or 2 (if account has parent, then show new subgrid, otherwise show standard subgrid). Maybe is there a way to avoid the JS-Code?

    Is there a good guide the make RETRIEVEMULTIPLE PLUGIN fromscratch?

  • Verified answer
    Pankaj Gogoi Profile Picture
    3,177 on at

    Hi,

    I have created a blog article regarding this requirement. Please check if it helps

    letssecure.wordpress.com/.../

    Best Regards

    PG

  • Dy365Fan Profile Picture
    on at

    Thx for the guide. Now i have two ways to solve my requirement.

    I thank everyone, you helped me a lot.

  • Verified answer
    LeoAlt Profile Picture
    16,331 Moderator on at

    Hi Dy365Fan,

     

    You could create two subgrids on account form as you said and use JS code to control the display of them.

     

    Here are steps.

    1.create a new subgrid related to childaccount.

             Create two sections to contain these two subgrid separately because Js code can’t hide the subgrid itself.

    1a.png

    1b.png

    2.write JS code.

    function showorhidesubgrid(executionContext) {
        var formContext = executionContext.getFormContext();
    
        var parentaccount = formContext.getAttribute("parentaccountid").getValue();
        var control1 = formContext.ui.tabs.get("SUMMARY_TAB").sections.get("ChildDoctors");
        var control2 = formContext.ui.tabs.get("SUMMARY_TAB").sections.get("ParentDoctors");
        if (parentaccount == null) {
            control1.setVisible(true);
            control2.setVisible(false);
        }
        else
         {
            control2.setVisible(true);
            control1.setVisible(false);
         }
    }
    

    3.Add your JavaScript code in a Script web resource.

    1c.png

    4.Add a OnChange event with this Script web resource to the opportunity entity form.

    (1) open the form and click Form Porperties.

    (2) click Add button to add JS that you create just now.

    1d.png

    (3) select OnLoad event click Add button to add JS.

    1f.png

    (4) double-clcik the JS and set as following.

    1g.png

    5.Test.

    1h.png

    1i.png

    Best Regards,

    Leo

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 > Service | Customer Service, Contact Center, Field Service, Guides

#1
Tom_Gioielli Profile Picture

Tom_Gioielli 45 Super User 2025 Season 2

#2
Daniyal Khaleel Profile Picture

Daniyal Khaleel 27 Most Valuable Professional

#3
Soundari Profile Picture

Soundari 15

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans