function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Adu86Adu86 

Validation Rule to Fire on Parent Object verifying the Child Object field values

Hi,

I have a requirement to create a validation rule to fire on the parent object field change by checking the value for the child object field.
For Example:
Parent Object Picklist Field Name = Stage
Child Object Field Name = Premium

Need a Validation rule to fire whenever the picklist value " Stage" is changed to "Bound", the value on the field "Premium" should be greater than Zero before the parent record is saved.

Is it possible through Validation rules? Or is there any other way?

Thanks

 
Best Answer chosen by Adu86
Apoorv Saxena 4Apoorv Saxena 4


Great..! Here you go:

Go to the Parent Object and create a Rollup summary field label it Check_Premiuim__c(you can name it as you like it)
Then, Click Next
Now, the Summarized Object: Select the Child Object
Select Rollup Type: COUNT
From Filter Criteria, select Only records meeting certain criteria should be included in the calculation
Filter: Premium(Your Child object field) greater than 0
Click Save

Now, setup your validation rule on parent object....it goes like this -->>

AND(ISCHANGED( Stage ), ISPICKVAL( Stage , "Bound"),Check_Premiuim__c<=0 )

(Here Stage is your Parent picklist field name and Check_Premiuim__c is the rollup summary field you just created).

Be sure to use proper API names, the best way to do it is use Insert Field button.

Please, let me know if this helps..!!

 

All Answers

AmrenderAmrender
Hi Sni86

This could not be possible using Validation Rules. You have to write trigger for it.

Regards
Amrender
Adu86Adu86

What type of Trigger I need to Write? "After trigger" on Parent Object? Do you have any example to post here . Thank you
Apoorv Saxena 4Apoorv Saxena 4

It is possible through validation rule if you have an master detail relationship.
Is the relationship between your objects master-detail relationship??

If yes, then you can achieve it by validation rule.

Let me know if its master detail.

Adu86Adu86
Yes, It is a Master Detail Relationship between two objects. Can you please let me know how it is possible. Thanks
Apoorv Saxena 4Apoorv Saxena 4


Great..! Here you go:

Go to the Parent Object and create a Rollup summary field label it Check_Premiuim__c(you can name it as you like it)
Then, Click Next
Now, the Summarized Object: Select the Child Object
Select Rollup Type: COUNT
From Filter Criteria, select Only records meeting certain criteria should be included in the calculation
Filter: Premium(Your Child object field) greater than 0
Click Save

Now, setup your validation rule on parent object....it goes like this -->>

AND(ISCHANGED( Stage ), ISPICKVAL( Stage , "Bound"),Check_Premiuim__c<=0 )

(Here Stage is your Parent picklist field name and Check_Premiuim__c is the rollup summary field you just created).

Be sure to use proper API names, the best way to do it is use Insert Field button.

Please, let me know if this helps..!!

 

This was selected as the best answer
Adu86Adu86
Thanks for the idea. it worked for me. The only change I did is instead is filtering the premium > 0 I made it equal to Zero, so that I can collect all the records with Zero Estimated premiums and also I changed the validation rule creteria to Check_Premiuim__c>0.

Thanks for the help!!