Can I roll up fields from person accounts to an account? - Answers - Salesforce Trailblazer Community
Trailblazer Community
Ask Search:
Janet CutlerJanet Cutler 

Can I roll up fields from person accounts to an account?

I have a field on my Account object for a Debtor Number, we use the field for the main account. We are now letting individuals who work at these accounts have an account with us and are using Person Accounts for this but I would like to be able to have a roll up summary to show that there are individual person accounts linked to this Debtor Number and a roll up summary field of how many person accounts have this number. Can anyone help me achieve this?
 
 
Best Answer chosen by Janet Cutler
Ines GarciaInes Garcia

Hi Janet,

Roll-up helper may be an app to look at if you want the updates of 'count' within an hour batches, or look at their pricing for enterprise edition.

In dependance of how many Person Account records approx will be related to an account, you could look at declarative automation via Process Builder + Flow.

- Process Builder:
Runs on your Person Account when a record is created or edited
Criteria Node when (1) is person account & (2) the lookup to account IsChanged
Inmediate action to trigger a flow and pass variable of varAccountID which is reference via lookup to Account Record ID
User-added image
(using allocations custom object here instead of parson account, and relationship to opportunitites intead of account)

- Flow (autolaunched)
You will need 4 elements:

User-added image

1. FastLookup
Look up Accounts Where the Account ID equals to {!varAccountID} (you will have to create this variable which is passed by the process builder) & when ISPersonAccount = true
Collection Variable {!varCollectionPersonAccount} and store fields: ID (we will use this to 'count')

2. Loop
Loop through: {!varCollectionPersonAccount} in descending order
Loop Variable {!varSObjectPersonAccount}  (you will have to 'create new' sobject variable)

3. Assignment
{!varPersonAccountCount} (you will have to create this variable where we'll count the number of records)
use the 'add' operator and value of '1'

4. Record Update
End of the loop is to update our 'parent Account' with the count of related person accounts
Update Accounts Where the Account ID equals to {!varAccountID}
Update field (here is your custom number field to count the number of person accounts related to an account) with the value of your variable {!varPersonAccountCount}

Then save & Activate the flow, create the process builder as explained above to pass the variable. & test!

** Notes **
To consider: remove the avility to Delete those person accounts (and accounts) as count will not be trigger on delete.
This will work best if there aren't high volume of 'child records' as you don't want to hit governance limits.

Tada!

Ines

All Answers

Ines GarciaInes Garcia
Hi Janet,

Where in the person account record do you store the relationship to the 'Account'?

Being person account you wont have a 'master detail' being child of an account. So the 'out-of-the-box' rollup functionality is out of the picture at this stage.

So you have few options. Lets look at one:
- New field number on account
- Process builder that every time a person account is created with the custom relationship (unsure of how are related, lookup field on person account to Account object?) adds +1 to the new field.

We should consider if/when you would like to 'reduce' the figure in the rollup, ie if a person account cancelles the 'relationship' to the account, or if the person account cancells? 

Unsure of your business process. But I hope this helps you in the right direction?

Ines
Janet CutlerJanet Cutler
Thanks Ines, it helps a little. The field to store the relationship is really the Debtor field as it is the same Debtor number on the person account/s as the one main account. I did take a look a process builder but couldn’t get it to work so maybe I need the lookup field of Person Account to main account to do this I will have a look and see how I go. Thanks for the tips Kind Regards, Janet Cutler Digital and Insights Manager Modern Star Phone: 02 9938 0444 Mobile: 0488 226 044 Fax number: 02 9938 0495
Ines GarciaInes Garcia
Hi Janet,

Yes, you should relate the 2 records (person account to Account) if the Debtor number is a unique number field you may be able to 'update' all existing records mapping it with the Account 18 digits Id.

Once thats done you can look at process builder to update the 'count' of related Person Accounts.

Bear in mind as well yoru business process of when/if the Count should be reduced as mentioned before as will affect data assurance/quality.

Best,

Ines
Tom BlamireTom Blamire
You would need something like Roll-Up Helper to do this
Janet CutlerJanet Cutler
Thanks Ines, I have created the look up I think that will work. I have a question for you with the count field, the field is to relate teachers to a school so it is very likely they will move over time. So with the count can I do in one formula you add to the new count when its created but then when it is subsequently edited it may need to -1 from the original Debtor number and +1 to the new debtor number, does that make sense will that be possible? Kind Regards, Janet Cutler Digital and Insights Manager Modern Star Phone: 02 9938 0444 Mobile: 0488 226 044 Fax number: 02 9938 0495
Janet CutlerJanet Cutler
Thanks Tom, looks like a great App! Kind Regards, Janet Cutler Digital and Insights Manager Modern Star Phone: 02 9938 0444 Mobile: 0488 226 044 Fax number: 02 9938 0495
Ines GarciaInes Garcia

Hi Janet,

Roll-up helper may be an app to look at if you want the updates of 'count' within an hour batches, or look at their pricing for enterprise edition.

In dependance of how many Person Account records approx will be related to an account, you could look at declarative automation via Process Builder + Flow.

- Process Builder:
Runs on your Person Account when a record is created or edited
Criteria Node when (1) is person account & (2) the lookup to account IsChanged
Inmediate action to trigger a flow and pass variable of varAccountID which is reference via lookup to Account Record ID
User-added image
(using allocations custom object here instead of parson account, and relationship to opportunitites intead of account)

- Flow (autolaunched)
You will need 4 elements:

User-added image

1. FastLookup
Look up Accounts Where the Account ID equals to {!varAccountID} (you will have to create this variable which is passed by the process builder) & when ISPersonAccount = true
Collection Variable {!varCollectionPersonAccount} and store fields: ID (we will use this to 'count')

2. Loop
Loop through: {!varCollectionPersonAccount} in descending order
Loop Variable {!varSObjectPersonAccount}  (you will have to 'create new' sobject variable)

3. Assignment
{!varPersonAccountCount} (you will have to create this variable where we'll count the number of records)
use the 'add' operator and value of '1'

4. Record Update
End of the loop is to update our 'parent Account' with the count of related person accounts
Update Accounts Where the Account ID equals to {!varAccountID}
Update field (here is your custom number field to count the number of person accounts related to an account) with the value of your variable {!varPersonAccountCount}

Then save & Activate the flow, create the process builder as explained above to pass the variable. & test!

** Notes **
To consider: remove the avility to Delete those person accounts (and accounts) as count will not be trigger on delete.
This will work best if there aren't high volume of 'child records' as you don't want to hit governance limits.

Tada!

Ines

This was selected as the best answer
Ines GarciaInes Garcia
Hi Janet, 

Hope any of the answers helped, if so could you please select one of the responses as 'Best Answer'?

The selected 'Best Answer' is used to highlight the response to your question that has helped the most, so that when someone else looks at similar questions in the future quickly can identify the answer :)

Otherwise let us know where are you at so we can have a further look?