question

Upvotes
Accepted
791 10 10 16

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?

world-check#technology#productscreeningscreening-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.

1 Answer

Upvotes
Accepted
151 1 0 2

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.