web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

CRM 2013 - Update values throughout the hierarchy.

(0) ShareShare
ReportReport
Posted on by

Hi,

We're looking for the best approach to updating values throughout the hierarchy of Accounts for our CRM 2013 solution.

The Account entity form has two custom numerical fields: 'Number of employees' and 'Group number of employees'.

Also, an Account entity record can have 'Parent' Account as well as a 'Grand Parent' Account.

2543.accounts.png

'Group number of employees' is a sum of all 'Number of employees' values across all Accounts. We need to make sure that whenever the value of 'Number of employees' changes on any of the Accounts the 'Group number of employees' will be updated and the value redistributed across the hierarchy.

i.e.:

- If 'Number of employees' is updated on AC 1 from 0 to 50, the 'Group number of employees' number should be updated to 550 on all accounts - AC1, AC2, AC3, AC4, and AC5.

- If 'Number of employees' is updated on AC 2 from 250 to 350, the 'Group number of employees' number should be updated to 600 on all accounts - AC1, AC2, AC3, AC4, and AC5.

- If 'Number of employees' is updated on AC 4 from 100 to 500, the 'Group number of employees' number should be updated to 900 on all accounts - AC1, AC2, AC3, AC4, and AC5.

 

We've been trying to use the Generic Rollup solution (https://crmgenericrollup.codeplex.com/) however, this will work only when updating Parent records but not Child.

Any help and suggestions are appreciated.

Many thanks.

*This post is locked for comments

I have the same question (0)
  • Verified answer
    Aiden Kaskela Profile Picture
    19,696 on at

    Hi,

    Since you're working in 2013, your options are more limited than in 2015 (which has an Under condition). I think you'll need to handle this recursively in a plugin. Register a plugin on the account that fires when No. of Employee changes. Here's the plugin logic:

    1. When that field is updated, get the root account in your hierarchy. From your account, keep getting the parent account until there isn't one. In your example, you'd end up with AC1
    2. Keep a list of all accounts that need to be updated and add AC1
    3. Query for all accounts with a parent account IN (account's at that level - AC1). This should return AC2 and AC3.
    4. Add this list of accounts to the list in step 2
    5. Repeat step 3 with the accounts at the new level (2 & 3, returns 4 & 5). Continue until you get no more results, so you're at the bottom of the hierarchy.
    6. With the full list of accounts (from step 2), calculate the new group total and set that field on each account.
    7. Use a ExecuteMultipleRequest to update all of those accounts in a single SDK call.

    That should do it. If you had 2015, you could simplify steps 3, 4, and 5 by querying for accounts UNDER the root, but the rest of it would be the same. If you don't have any development resources, I could build this out for you pretty quickly.

    Hope this helps! I'd appreciate if you'd mark this as Answering your question.

    Thanks,

      Aiden

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the April Top 10 Community Leaders

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
ScottDurow Profile Picture

ScottDurow 2

#2
GJones Profile Picture

GJones 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans