TransWikia.com

Validation rule not working with Rollup Summary field

Salesforce Asked by Mahwish on January 11, 2021

I have a rollup summary field which just calculates sum of weights from child records and I am trying to apply a validation rule that if IsActive = true && Sum_of_Weights != 100 then throw an error. Because child weights can be entered more or less than 100 when parent is inactive but once it’s active, weight sum must be 100.

It gives me an error even on positive condition when parent is active and sum is 100 and it’s not letting me edit parent record.

Any suggestions?

2 Answers

This objective does not make sense to me unless the intent is to prevent marking the parent object as Active until Sum_of_Weights__c equals 100. If this is the case, you can include an ISCHANGED() function in your formula:

ISCHANGED(IsActive__c) && IsActive__c && Sum_of_Weights__c != 100

Then your validation will only go off if a parent object is moved from IsActive__c = false to IsActive__c = true without Sum_of_Weights__c being 100.

You may also need a validation rule on the child object to prevent children from being added or removed from an Active parent.

Answered by David Reed on January 11, 2021

I believe your Parent-Child object are connected via Master Detail relationship. With your validation rule, you will never be able to insert/create Parent (who is active, but having no child). Are you expecting all of your parents will have childrens and also their sum of weights will be exactly 100? Requirement seems a little strange to me. Suggesting you to please recheck the requirements.

But I would like to share this information here for your reference. The Validation Rule will run on a Parent record 'save' before the record is saved, so before the Total Weight Rollup is re-calculated.

Answered by Sudipta Deb on January 11, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP