You can use cross object validation rules to do this.
1. Create a custom field on the account object that will hold the status of the screening case and make sure it is populated using a flow or custom code. There is an example of how to do this in the Tutorials section of the developer portal, however the method you chose will depend on your data model/architecture.
2. Create a cross object validation rule on the opportunity object that references the custom field you created e.g. Risk_Screening_Status__c and then define the status values that you want to trigger the rule under e.g.
AND( OR(CONTAINS(Account.Risk_Screening_Status__c, "Completed - do not proceed"), CONTAINS(Account.Risk_Screening_Status__c, "Pending compliance review"), CONTAINS(Account.Risk_Screening_Status__c, "Not started"), CONTAINS(Account.Risk_Screening_Status__c, "Screening in progress"), CONTAINS(Account.Risk_Screening_Status__c, "Risk Identified - Do not Proceed")) ,ISPICKVAL(StageName, 'Closed Won'))
Obviously tweak the formula so that it works for the status values you have defined for your organisation. The above should work with the example referenced on the dev portal.
Hey everyone,
Just wanted to jump in with my thoughts on this topic. I totally understand the frustration of dealing with opportunities closing prematurely in Salesforce due to the screening case not being completed. It can really impact your workflow and cause missed opportunities.
DevTrev, you're definitely not alone in facing this challenge. What has worked for me in similar situations is using cross-object validation rules. It's a powerful way to ensure that opportunities don't close until the necessary criteria are met.
Creating a custom field on the account object to track the screening case status is a great idea. You can then set up a cross-object validation rule on the opportunity object that checks this custom field before allowing an opportunity to be closed.
@hannah.quinn01, your provided solution seems solid. The formula you've shared seems to cover the scenarios where the screening case is still in progress or not yet completed, preventing the opportunity from closing prematurely.
In terms of advice, I'd recommend thoroughly testing this setup in a sandbox environment before implementing it in your production org. Make sure all possible cases are accounted for and that the validation rule doesn't inadvertently block legitimate closures.