3

So I'm having a requirement where I will be creating a checkbox in the Accounts object and each user has a maximum of 10 checks that they check for the checkbox for different Account records.

So I thought creating a counter at the User object level will work but I'm not able cross reference Account fields from the User object level.

What is the solution ? If it is Process Builder can someone help me how I can write a flow condition which should check for a count less than 10 and also increment the field whenever a check has been made by the user upto 10 checks.

2

Process Builder is not capable of record validation, so no. A Validation Rule can enforce that at most 10 boxes are checked, but not by whom. The criteria would be something like:

10 <=
IF(Checkbox1__c, 1, 0) +
IF(Checkbox2__c, 1, 0) +
IF(Checkbox3__c, 1, 0) +
IF(Checkbox4__c, 1, 0) +
IF(Checkbox5__c, 1, 0)

Process Builder could help you track which boxes were checked by whom, but at that point I think you would probably need to use an Apex Trigger to count these values by user.

To determine how many Account records a User has checked this box for, you could create a lookup called, say, Checked_By__c, which I think you could update with Workflow whenever the box is checked with {!$User.Id}. You should also add a Workflow that clears the lookup if the box gets unchecked. From there, you can use Andrew Fawcett's Declarative Rollup Summaries for Lookups tool in order to roll up this lookup to a new field on User called, say, Boxes_Checked__c. Once you have done the above, the Validation Rule is fairly straightforward: Boxes_Checked__c > 10. You might want the rule to be on Account though to be more clear (and add to the checkbox), so you would change that to $User.Boxes_Checked__c > 10.

More succinctly delineated steps:

  1. Workflow Rule - Populate lookup when box is checked
  2. Workflow Rule - Clear lookup when box is unchecked
  3. DLRS - Roll up number of checked Account records
  4. Validation on check box: $User.Boxes_Checked__c > 10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.