Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)

How to add in-direct related Records to a sub-grid on a form.

Posted on by 377

Hello All,

I am having 3 entities which are like  A(Nto1)--->B<----(Nto1)C. There is no direct relation between A & C. But when user creates a new Entity 'A' record, he has to select record B( from drop down ) and when user saved that record , there is a requirement to auto populate all related C entity records(related to B) on form A sub-grid. I'm thinking to write plug-in, but i'm not sure how to add to the sub-grid. please let me know if there's any simple way to achieve this . Thank You

*This post is locked for comments

  • Suggested answer
    Sreevalli Profile Picture
    Sreevalli 3,256 on at
    RE: How to add in-direct related Records to a sub-grid on a form.

    Hi,

    Thanks for details.

    In that case you don't need to create additional relationship between Account and Plan. Just create a "Quick View Form" on account and add Invoice sub-grid to that form.

    Then go to Plan form and add newly created Account Quick View form on it. So that automatically you can see Account related Invoices on Plan form.

    Coming to the invoice calculation part, you need to trigger plugin on Plan record creation and retrieve all account related invoices and do the required calculation to populate the sum. You also need to trigger same plugin on create and update(account lookup field) of Invoice record, as it should look for invoice related account's plans and then update invoice balance on each individual plan record.

    Just to summarise, your plugin should trigger on

    1. Create of Plan
    2. Update of Plan
    3. Create of Invoice
    4. Update of Invoice
  • ZeroHar Profile Picture
    ZeroHar 377 on at
    RE: How to add in-direct related Records to a sub-grid on a form.

    there's 2 entities in my  org, which are account ,(1---N relationship) invoice .  i have to create another entity 'plans', which will have n to 1 relationship with account. so whenever user selects 'account' record from 'Plans' ,  it should auto populate all  'account' related  'invoices' on 'plans' form and i have to calculate all the balances from 'invoices'(auto-populated on plans) and displays it on the form dynamically.

  • Suggested answer
    Sreevalli Profile Picture
    Sreevalli 3,256 on at
    RE: How to add in-direct related Records to a sub-grid on a form.

    Then you should have N to N between A to C and retrieve B related C records and add records to relationship.

  • Suggested answer
    gdas Profile Picture
    gdas 50,085 on at
    RE: How to add in-direct related Records to a sub-grid on a form.

    You don't need to add the subgrid records after create the record A , it will automatically show the related record using quick view form. So you can trigger your plugin in another event I guess.

    BTW , what is your requirement can you please clarify , my suggestion is as per your initial question and you can achieve this using quick view form and without any code.

  • ZeroHar Profile Picture
    ZeroHar 377 on at
    RE: How to add in-direct related Records to a sub-grid on a form.

    hi,

    but whenever related records added to the grid, i have to trigger another plug-in on the association message.

  • Suggested answer
    gdas Profile Picture
    gdas 50,085 on at
    RE: How to add in-direct related Records to a sub-grid on a form.

    Hello,

    Why you are thinking to write plugin ? You can do this using Quick View Form and without having any code . Please follow below steps -

    - Create a quick view form in the Entity B and add subgrid of entity C over there.

    - Include quick  view form in the Entity A form , using B entity lookup field. As you mentioned you are choosing B entity lookup while creating record A.So the quick view form will auto populate the  C entitiy records.

    www.magnetismsolutions.com/.../how-to-add-a-quick-view-form-in-microsoft-dynamics-365

  • ZeroHar Profile Picture
    ZeroHar 377 on at
    RE: How to add in-direct related Records to a sub-grid on a form.

    Sreevalli,

    Thanks for the answer. Looks scenario 1 works for me , im already having a lookup on A for B , C also has lookup for B,  I will create a lookup on C with target type A, and autopopulate the lookup like you said using plug-in .but what if multiple A records have same B record reference value on their lookup, how we will keep the entity reference between multiple  A(2 records having reference to same B record) records and C records.

  • Suggested answer
    Sreevalli Profile Picture
    Sreevalli 3,256 on at
    RE: How to add in-direct related Records to a sub-grid on a form.

    Hi,

    Above explanation seems little confusion in terms of relationships you explained. So, I am giving you 2 possible scenarios

    Scenario 1 : If A to B is N to 1 that means A will have B lookup(B will have A sub-grid). B to C is 1 to N that means C will have B lookup(B will have C sub-grid).

    You need to create A lookup field on C entity to add C sub-grid on A form

    You can trigger a plugin on create of A or on update of B lookup field on the A form and retrieve all the B associated C records. Then, update all the retrieved C records with target details in A lookup as EntityReferance (i.e all C records related to B must be filled with target A in the lookup). This way you can auto populate the C records in sub-grid on A form.

    Scenario 2 : If A has B lookup i.e N to 1 and B has C lookup i.e N to 1

    Then, you can create a lookup of C on A and just write javascript on change of B to populate C lookup or you can go for system workflow to populate the same on create/update(server side action)

    Hope, Scenario 1 is what you are looking for, let me know if my understanding differs.

    Please note you can't add sub-grid on forms without a relationship in place. If in case you want to display records in sub-grid without relationship then you should go for Custom HTML page.

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