+ Start a Discussion
Hermes GomezHermes Gomez 

Validation Rule for Picklist value to not be selected if there is no Picklist value X on another related record


Hello guys,

I am trying to set a validation rule in which the picklist field "stage" on my object cannot go to the value "Underwriting", unless there is a record on the related object "carrier submissions" that has a picklist value "Submitted" on their own "stage" field.

Can you guys help me on this ? 

I know it goes along the IF function however im having a hard time. Please Help

User-added image
LBKLBK
Hi Hermes,

A validation rule alone cannot fulfill the use case, because it cannot look at multiple records to decide if at least one of them are submitted.

What you need is a field (probably a boolean) in your Insurance Quota object, which will be checked when a carrier submission is "Submitted", using a trigger.

And you can use this boolean in your Validation Rule to achieve your use case.

PS: If your relationship is Master - Detail, you can use Roll up summary field instead of the Boolean field and trigger.

 
Hermes GomezHermes Gomez

Carrier Submissions have a Master - Detail relationship with Carrier(Master). 

What should i write on the Boolean field, how could i do the trigger?

 

Sorry, im just a starter

LBKLBK
Since you have a master - detail relationship between Carrier and Carrier Submissions, you can use a Roll Up Summary field to achieve this without a Trigger.

Step 1.
Create a Roll up Summary field in Carrier object (Master)
1. Create a Roll up summary field named "Carrier Submissions Count" - API Name "Carrier_Submissions_Count__c"
2. Choose Rollup Type as "Count"
3. Enter filter criteria as "Stage__c = 'Submitted'"

Stage 2:
Create your validation rule in Carrier object. Your validation rule would be as follows.
AND(Carrier_Submissions_Count__c <= 0, ISPICKVAL(Stage__c , "Underwriting"))
Let me know how it goes.