0

I am struggling with one task as I want to create a validation rule for the Opportunity object in which the contact owner is related.

  • So whenever the stages in opportunity after stage 4 it may have at least one contact owner, total stages in opportunities are from stage 1 to stage 8,

So the requirement is when the stage changes above 4 there must be at least 1 contact role against the opportunity.

I tried to make a validation rule but wasn't able to find a contact role field as this is not a field on the Opportunity Object, but it shows in related list of opportunity page layout. Can anyone pls help me?

2 Answers 2

1

Validation rules can only execute on fields for the Opportunity and any lookup fields from Opportunity (like Account)

OpportunityContactRole is a child of Opportunity and VRs can't look into children

Hence, you will need to count the number of OpportunityContactRoles on Opportunity. Given a custom count field (OCR_Count__c) on Opportunity, you can then write the VR comparing Stage to the count.

How to get the Count of OCR on Opportunity?

  • Rollup Summary fields are not supported for the Opportunity -> OpportunityContactRole relationship so ..

  • Use DLRS (best solution - works for add/deletes - free). If you're not using DLRS yet, this is a great time to add it to your org

  • use Appexchange Rollup Helper (freemium) - works for adds-deletes

  • Use Flow (this solution works for adds only)

0

You can create a Record-Triggered Flow that checks if the opportunity is in a particular stage, query to see if there are any contact roles assigned to the opportunity, and use the Error flow element to present an error if there are no roles assigned.

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .