jamessimone / apex-rollup

Fast, configurable, elastically scaling custom rollup solution. Apex Invocable action, one-liner Apex trigger/CMDT-driven logic, and scheduled Apex-ready.
MIT License
220 stars 30 forks source link

Bypass Validation Rules #440

Closed jsteve06 closed 1 year ago

jsteve06 commented 1 year ago

Is there a way to have the rollups bypass validation rules on the parent object? The product Rollup Helper has a custom setting that you can reference in the validation rule so that the rule is invalid when it updates the record. A lot of orgs that I work on have tons of validation rules so bypassing them to allow the rollups to work is crucial.

jamessimone commented 1 year ago

@jsteve06 you have a few options:

Let me know if either of those approaches would work, or if you were thinking of something else. Thanks!

jsteve06 commented 1 year ago

@jamessimone Well I am not a developer so option one is out :)

Option 2 would work but I can't get it to work. If I reference it in the validation rule at either the org default or profile level, it is always on or off. So either I say AND(ISPICKVAL(Activec,''), $Setup.RollupSettingsc.IsEnabled__c = true ) and the validation rule still fires, or I set it to false and the validation rule works but is not bypassed when the rollup occurs.

In my ideal world there would be another custom setting like "Bypass Validation Rule". That custom setting would be referenced in the validation rules. When the rollup updates the record the setting would return 'true' otherwise it would return false. So then you'd just add $Setup.RollupSettings__c.Bypass_Validation_Rule = false to your validation rules. Hopefully that makes sense.

jamessimone commented 1 year ago

@jsteve06 thanks for the additional context. I should be able to add another custom setting for this soon

jsteve06 commented 1 year ago

That would be great. Validation rules are the bane of my existence :)

jamessimone commented 1 year ago

@jsteve06 #441 added support for this - check the Rollup Plugins section of the README, or the release notes for more info!

jsteve06 commented 1 year ago

This is awesome @jamessimone! I have it setup and working in my Dev org. Took me a minute to figure out I needed to add a record to the Custom Meta Data rollup Plugin Parameter. Once I got that sorted out it worked like a charm.

image

Thanks so much for adding this functionality.

jamessimone commented 1 year ago

No problem - couldn't have done it without you suggesting it! Thanks for making open source better by raising an issue and providing me with an excellent summary of what you were looking to do.