1

I am working on a requirement where a particular account should have only four contacts if more than four contacts then a validation error should pop up.

Since a roll-up summary is impossible as there is no master detail relation I tried an alternative way using flow builder.

I created a field named ContactTotal(number field) and a record-triggered flow for this. enter image description here

enter image description here

enter image description here

enter image description here

enter image description here

Here I am getting the number of current contacts and adding it to the earlier created number field. This works fine for creating the record condition as I specified the triggering condition.

Can I do something in the flow to update the value if the record is deleted as well?

Also, the number field total contact has an initial value as blank instead of the number of contacts which gets updated when a record is created, but until then it remains blank. Is there any solution for this too?

1
  • Use DLRS to do the rollup for you -- no need to write a flow to count these Contacts
    – cropredy
    Commented Nov 26, 2022 at 18:19

1 Answer 1

0

I see that in Get Account you are getting multiple Accounts, can the contact be assignned to multiple accounts? if so you have to loop throug each account and for each, 1.get the number of contacts, 2. assign the value to the field you created.

To answer your question, you can create a flow (or change this one to On record created and updated) that if the Organization field (or whatever the lookup field for the account is called) is changed, then have a recount of the contacts in the parent account (by repeating the process you did in the flow). This again will only work if the relationship is one account to many contacts. Otherwise, you need to use the object linking Account and contact relationship.

Contact-Account relation is the AccountContactRelation object. You should try creating your flow from that object. Before you get to the flow, you can try a roll-up summary on that object. Here is more information about the object fields etc. developer.salesforce.com/docs/atlas.en-us.object_reference.meta/…

Updated 11/27/22

1
  • Rather than adding as a comment any additional info that is important to the answer, please instead edit your answer (click "Edit" at the bottom-left of your post where you see "Share Edit Follow Flag") and update it with the information. Most people will make a note like "##### UPDATED" or "Edit" or similar, and then include the new material.
    – Moonpie
    Commented Nov 27, 2022 at 5:22

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .