Dynamic Control of Automations on Salesforce (chapter 3 of 3)

Dynamic Control of Automations on Salesforce

This is chapter three of this saga, and we will show you how to use Custom Settings for Dynamic Control of Automations on Salesforce. 

Custom Settings

Custom settings are like custom objects and enable application developers to create custom sets of data, as well as create and associate custom data for an organization, profile, or specific user. All custom settings data is exposed in the application cache, which enables efficient access without the cost of repeated queries to the database. This data is then available for formula fields, validation rules, flows, Apex, and the SOAP API.

Your team and ours working as one

Access Top IT Talent in your timezone at half the cost

We will create a list “Custom Setting” for triggers and Hyperarchy for Validation Rules (Figure 1).

“Custom Setting” for triggers and Hyperarchy for Validation Rules (Figure 1).
[Figure 1: Custom Setting]

For Apex Triggers 

I will suppose the needed control apex, validation rules automation independent each from another, so for that the first step will be create 2 different “Custom Settings”.

Custom Setting Type List
[Figure 2: Custom Setting Type List]
Add some records, one records for each trigger we want to control.

List of triggers that need control
[Figure 3: List of triggers that need control]
AccountTrigger custom setting record example active true
[Figure 4: AccountTrigger custom setting record example active true]
Next it is required to create an apex trigger class related to the object we would like to control the automation, in this case was created for “Opportunity” object.

Trigger for Opportunity object
[Figure 5:  Trigger for Opportunity object]
For order you code, it’s a good practice if you use and extra class for add method related to query your “Custom Setting” status. For this example, I created “Utility” class with the method isTriggerActive.

Utility class for query Custom Setting status
[Figure 6: Utility class for query Custom Setting status]

For Validation Rules 

Go to “Setup” -> “Custom Setting” and create “Validation Handler” setting.

Validation Rule Custom Setting
[Figure 7: Validation Rule Custom Setting]
After creating click on “Manage” and add one records for “System Administrator” profile with rules deactivated and another one for a “Sales” profile with check box active. With this configuration, any rule should be bypassed   for any user with “System Administrator” profile when we check into conditional formula.

Profiles associated
[Figure 8: Profiles associated]

Setting details

Setting records Details
[Figure 9: Setting records Details]
Create validation rule on opportunity object using on conditional out setting create on the previous step.

Validation Rule on Opportunity object
[Figure 10: Validation Rule on Opportunity object]
Previous Chapter “Custom Metadata Types”: Dynamic Control of Automations on Salesforce (chapter 2 of 3)

Note: You could check all the metadata and code I used for this example on this repository on github: cristiaan30033/Salesforce-Dynamic-Control-of-Automations: Examples how to implements controls for triggers, validations rules, etc. on salesforce platform (github.com)

Why you should augment your team with Folder IT

Outsourcing or Augmenting your AI Team with Folder IT professionals is a cost effective solution that does not sacrifice on quality nor communication effectiveness. Our teams are qualified for working with all the latest technologies and for joining you right away.

Request a quote now for outsourcing your project or staff augmentation services to Argentina.

Get in Touch