Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/scolladon/dce
Apex Dynamic Code Execution
https://github.com/scolladon/dce
apex process-builder salesforce trigger workflow-rule
Last synced: 17 days ago
JSON representation
Apex Dynamic Code Execution
- Host: GitHub
- URL: https://github.com/scolladon/dce
- Owner: scolladon
- Created: 2018-03-06T16:04:46.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2018-11-28T21:54:07.000Z (about 6 years ago)
- Last Synced: 2024-12-09T04:42:14.940Z (2 months ago)
- Topics: apex, process-builder, salesforce, trigger, workflow-rule
- Language: Apex
- Size: 10.7 KB
- Stars: 2
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Apex Dynamic Code Execution
Apex Library to dynamically prevent/allow code execution
Test Coverage : 100%This Library aims to dynamically control code execution in apex, validation rule and workflow rule / Process Builder.
## Getting Started
Here we go !
### Installing
### Caching
This implementation use Platform Cache (Session Cache).
Ensure you have platform Cache enabled or the deployment will fail.If you **do not want** the version with the Platform Cache, copy the code in the class DCE_NOCACHE.txt to DCE.cls instead
### Trigger
In order to apply the dynamic code execution, wrap you code in a if statement :
```java
trigger myTrigger on myObject (after update) {
if(DCE.allow('myTrigger')) {
MyObjectTriggerDelegate();
}
}
```If you user as the value "myTrigger" selected in the multipicklist DCE_TriggerBlackList__c the DCE.isAllowed('myTrigger') condition will be false.
You can force to prevent all in your code or in your script either by checking the field DCE_AllTrigger__c or by setting the preventAll boolean to true dynamically :
```java
DCE.preventAll = true;
```You can force to prevent execution after n execution :
```java
DCE.allowUntil('myTrigger', 2);
```
This way the trigger myTrigger will be executed 2 times.### Validation Rule
In order to by pass validation rule you can configure your user with the multipicklist DCE_VBL__c to filter what you want to prevent or you can use the checkbox DCE_AV__c to prevent all.
Then configure you're validation rule this way :
```java
Not($User.DCE_AV__c) && NOT(INCLUDES($User.DCE_VBL__c,'MyValidationRule')) && MyConditions
```### Workflow Rule, Process Builder
In order to by pass Workflow rule or Process Buidler you can configure your user with the multipicklist DCE_WBL__c to filter what you want to prevent or you can use the checkbox DCE_AW__c to prevent all.
Then configure you're workflow rule / Process Builder this way :
```java
Not($User.DCE_AW__c) && NOT(INCLUDES($User.DCE_WBL__c,'MyFlow')) && MyConditions
```## Authors
* **Sebastien Colladon** - *Initial work* - [scolladon](https://github.com/scolladon)