question

Upvotes
Accepted
791 11 16 20

How can I prevent opportunities from closing in Salesforce when an account record hasn’t completed screening yet, if the screening case object is locked and accessible only to licensed users?

#technology#productworld-checkscreeningscreening-apiscreenerrisk
icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Upvotes
Accepted
151 1 1 3

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.


icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Upvotes
1 0 0 0

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.


icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.