forked from PoojMane/TriggerFactory
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUtil.cls
More file actions
34 lines (32 loc) · 2.11 KB
/
Copy pathUtil.cls
File metadata and controls
34 lines (32 loc) · 2.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
/*******************************************************************************************
* @Name Util
* @Author Pooja Mane <poojmane@in.ibm.com>
* @Date 10/02/2021 <dd/mm/yyyy>
* @Group Utility Methods
* @Description Class containing commonly used methods which can be reused
*******************************************************************************************/
/* MODIFICATION LOG
* Version Developer Date Description
*-------------------------------------------------------------------------------------------
* 1.0 Pooja 10/02/2021 Initial Creation
*******************************************************************************************/
public class Util {
/**************************************************************************************
* @Description This method fetches the trigger active status based on running user profile
* @Param objName - SObjectType
* @Return Boolean - Value returned on trigger active status.
* @Example
* Util.getDisabledTrigger(Case)
**************************************************************************************/
public static Boolean getDisabledTrigger(SObjectType objName){
Boolean isTriggerActive = false;
Schema.DescribeSObjectResult schema = objName.getDescribe();
String objectName = schema.getName(); // Get the object API name in string format.
Id profileId = UserInfo.getProfileId(); // Get the Profile Id of the running user who invoked the trigger
TriggerPreferenace__c triggerPreferenace = TriggerPreferenace__c.getInstance(profileId);// Get the custom setting instance for the profile Id
if(triggerPreferenace != null && triggerPreferenace.sObject_Name__c != null && triggerPreferenace.sObject_Name__c.containsIgnoreCase(objectName)){ // check if the custom setting object name field contains the running trigger object{
isTriggerActive = triggerPreferenace.IsActive__c;
}
return isTriggerActive;
}
}