Pages

Thursday, August 15, 2013

Salesforce: How to Make Validation Rule only effect for Production Instance

Background: how to make certain Validation Rule only effect for Production instance, but not in sandbox instances?

Solution:
1. Deactivate the validation rule in sandbox
This is very basic and simple solution, it works, but not really nice if you have many validation rules need to deactivate in sandbox, admin need to deactivate each validation rule in all objects.
Also, when sandbox refresh, admin need to re-deactivate all validations rule again.

2. Modify the validation rule only work in Production instance
Step 1. Get your Salesforce Production Organization Id
Go to Setup - Administration Setup - Company Profile - Company Information
Look for Salesforce.com Organization ID

















Step 2. Add Organization ID into validation rule
Example, your current Validation Rule error formula:
Type__c = "A" & Amount < 1000
Modify this to:
Type__c = "A" && Amount < 1000 && $Organization.Id='00D300000000SHq'

Done, but see this blog that Salesforce will automatically change the value of Organization Id in Validation Rule and Workflow formula when you use $Organization.Id formula of production instance.

No comments:

Post a Comment