Showing posts with label hierarchy custom setting apex controller. Show all posts
Showing posts with label hierarchy custom setting apex controller. Show all posts

Thursday, November 17, 2022

Hierarchy Custom Setting context in Apex

/*** 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

}

} 

Validation in flow input text field in sfdc: Maximum 255 characters limit

The input text field validate in sfdc flow behaves opposite of the generic sfdc validation rule.  Here the validation formula is evaluating ...