Skip to main content

Notifications

Announcements

No record found.

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.

  • LeoAlt Profile Picture
    LeoAlt 16,331 on at
    RE: See all related Records from all Child Accounts (1:N from Account to CustomEntity) in Dynamics and Portal

    Hi Partner,

    Thanks for your recognition :)

    Have a nice day.

    Regards,

    Leo

  • Verified answer
    LeoAlt Profile Picture
    LeoAlt 16,331 on at
    RE: See all related Records from all Child Accounts (1:N from Account to CustomEntity) in Dynamics and Portal

    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

  • Dy365Fan Profile Picture
    Dy365Fan on at
    RE: See all related Records from all Child Accounts (1:N from Account to CustomEntity) in Dynamics and Portal

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

    I thank everyone, you helped me a lot.

  • Verified answer
    Pankaj Gogoi Profile Picture
    Pankaj Gogoi 3,177 on at
    RE: See all related Records from all Child Accounts (1:N from Account to CustomEntity) in Dynamics and Portal

    Hi,

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

    letssecure.wordpress.com/.../

    Best Regards

    PG

  • Dy365Fan Profile Picture
    Dy365Fan on at
    RE: See all related Records from all Child Accounts (1:N from Account to CustomEntity) in Dynamics and Portal

    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
    LeoAlt Profile Picture
    LeoAlt 16,331 on at
    RE: See all related Records from all Child Accounts (1:N from Account to CustomEntity) in Dynamics and Portal

    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

  • Pankaj Gogoi Profile Picture
    Pankaj Gogoi 3,177 on at
    RE: See all related Records from all Child Accounts (1:N from Account to CustomEntity) in Dynamics and Portal

    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.

  • Dy365Fan Profile Picture
    Dy365Fan on at
    RE: See all related Records from all Child Accounts (1:N from Account to CustomEntity) in Dynamics and Portal

    check my edit - I hope is clear now :)

  • Pankaj Gogoi Profile Picture
    Pankaj Gogoi 3,177 on at
    RE: See all related Records from all Child Accounts (1:N from Account to CustomEntity) in Dynamics and Portal

    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
    Dy365Fan on at
    RE: See all related Records from all Child Accounts (1:N from Account to CustomEntity) in Dynamics and Portal

    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 :)

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

Congratulations 2024 Spotlight Honorees

Kudos to all of our 2024 community stars! 🎉

Meet the Top 10 leaders for December

Congratulations to our December super stars! 🥳

Start Your Super User Journey

Join the ranks of our community heros! 🦹

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 230,466 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans