News & Resources — Tips & Tricks

The Custom Setting Every Administrator Needs

Tip of the month: January – by Senior Consultant Julianne Boley

Julianne Boley
As an administrator, you may want to protect data integrity by setting up validation rules that prevent users from creating, editing, and/or deleting data. Often in this situation there are certain users that are exceptions to the rule and you may find yourself writing ‘$user’ or ‘$profile’ exceptions into your validations rules to allow those users to modify records even though most users cannot.  Maintenance of the validation rules can be cumbersome over time, but using a custom setting to provide for validation rule exceptions can make this process much easier by allowing you to edit the exceptions in one place and apply it to all rules where the setting is referenced.

Business Use Case:
ABC Corporation has an integration between their ERP system and Salesforce.com.  Due to this integration, they want to remove the ability to edit account names within the Salesforce.com system.  However, the system administrator and users with the contract manager profile should be allowed to edit the account names within Salesforce.com to provide for contract verbiage requests.

Custom Setting Solution:

  • From the Setup page, navigate to Build>Develop>Custom Settings

pic1

 

 

 

 

 

  • Click the New button;  Choose a label/name for your rule, Setting Type=Hierarchy, Visibility=Public, and enter a description

pic2

  • Create on the New button to add a custom field to your new Validation Rule Exception custom setting object
  • Choose the Checkbox field type and label/name your field ‘Run Validation Rules’ and give it a default value of Checked

 

pic3

Now that we have created our custom setting object and our default behavior for running validation rules, we’ll add our profile exceptions.

  • From our new custom setting object, click on Manage

pic4

  • Set the organization default behavior by clicking the New button above the Default Organization Level Value;  The values will default appropriately in this instance to show that the default behavior will be to run validation rules, so you can just save.
  • Begin adding your exception profiles by clicking New

 

pic6

 

For this example, I will add the System Administrator with Run Validation Rule=Unchecked and the Contract Manager with Run Validation Rule=Unchecked:

pic7 pic8

The next step is to create a validation rule that prevents changes to the account name, unless the profile is part of our custom setting.  When you begin writing your validation rule, you will choose to include the new custom setting which will be visible when you click Insert Field:

pic9

  • Enter the additional criteria that should trigger the validation rule error (in this case we want the error message to appear when the account name is changed and our custom setting field  is true

pic10

  • Set up your error message and error message location and save

You can test out your new rule by attempting to edit an account name as a system administrator and then logging in as someone with any profile other than system administrator or contract manager and repeating this process to make sure you receive the error message.

In using the custom setting to determine which profiles kick off validation rules and which do not, you can maintain your validation rules and workflows from one location.  When management decides that contract managers no longer have the permission to edit account names, you can remove their profile from your custom setting rather than editing your validation rules.

Custom settings can be used in many ways (formula fields, workflow rules, as well as setting up long picklists that can be edited more easily).  You can read additional information in Salesforce Help or contact your Buan Consultant for any questions you may have.