/*** Download is a checkbox in Hierarchy Custom Setting ****/
public Hierarchy_Custom_Setting_Controller{
public static returnType methodName(){
Boolean isAllowed = false;
// Get current User custom setting. Priority 1
Hierarchy_Custom_Setting__c userLevel = Hierarchy_Custom_Setting__c.getValues(UserInfo.getUserId());
// Get current profile custom setting. Priority 2
Hierarchy_Custom_Setting__c profileLevel = Hierarchy_Custom_Setting__c.getvalues(UserInfo.getProfileId());
// Get current Organization custom setting. Priority 3
Hierarchy_Custom_Setting__c orgLevel = Hierarchy_Custom_Setting__c.getvalues(UserInfo.getOrganizationId());
if(userLevel != null) {
isAllowed = userLevel.Download;
}else if(profileLevel != null) {
isAllowed = profileLevel.Download;
}else if(orgLevel != null) {
isAllowed = orgLevel.Download;
}
if(!isAllowed){
return;
}
//Logic to excute start from here
}
}
No comments:
Post a Comment