+ Start a Discussion
TheLearnerTheLearner 

how to use custom label-- urgent

Hi Experts,

I have custom lable it contain 5 email ids, so i want to use it in the apex class, could anyone tell me how to use it please, because custom label support only one string it thrwoing an error because im using more than one in the label.
Best Answer chosen by TheLearner
ManojjenaManojjena
HI The learner,
You can access your custom lable like below .
String emailStr=System.Lable.Your lable Name;
List<String> emailList=new List<String>();
emailList=emailStr.split('EmailSeparator here ');
I think when you are storing into the Lable you have added one seperator just give that inside the split method .
Then use that list in you remail .
I think this wil help you .
Thanks
Manoj

All Answers

ManojjenaManojjena
HI The learner,
You can access your custom lable like below .
String emailStr=System.Lable.Your lable Name;
List<String> emailList=new List<String>();
emailList=emailStr.split('EmailSeparator here ');
I think when you are storing into the Lable you have added one seperator just give that inside the split method .
Then use that list in you remail .
I think this wil help you .
Thanks
Manoj
This was selected as the best answer
TheLearnerTheLearner
Hi Manoj,

I need to display forth coming date can you help me in this code please. here wpd contract contain field called End date based on this end date value we need to display forth coming date. First we will create WPD Contract with some End date, and we will create WPD Project object there we have look up field Contract here we need to display forth coming date.Eg: End date is 30-11-2015 and 5-12-2015 so here forth coming date is 30-11-2015 so this date is we need to select in the contract field which is there in the WPD porject, if user select 5-12-2015, then we need to throw an error already error is there at end which is highlated.

trigger WPD_UpdateWorkPackSeenDate_Project  on WPD_Projects__c (before insert, before update) {
    map<id,boolean> mapWPS_New = new map<id,boolean>();
    map<id,boolean> mapWPS_Old = new map<id,boolean>();
    if(trigger.isinsert){
        for(WPD_Projects__c project : trigger.new){
            if(project.Work_Pack_Seen__c==true)
                 project.Work_Pack_Seen_Date__c=system.today();   
        }
    }
    else if(trigger.isupdate){
          for(WPD_Projects__c NewProj : trigger.new)
              mapWPS_New.put(NewProj.id,NewProj.Work_Pack_Seen__c);
              
          for(WPD_Projects__c OldProj : trigger.old)
              mapWPS_Old.put(OldProj.id,OldProj.Work_Pack_Seen__c);
          
          for(WPD_Projects__c proj : trigger.new){
              system.debug('rrrrr-----'+mapWPS_New.get(proj.id));
              system.debug('tttttt-----'+mapWPS_Old.get(proj.id));
               system.debug('wwwwww-----'+proj.Work_Pack_Seen__c);
              if(mapWPS_New.get(proj.id)!=mapWPS_Old.get(proj.id) && proj.Work_Pack_Seen__c==true)
                 proj.Work_Pack_Seen_Date__c=system.today();    
          }             
    }
    
    //CH01.Start
    Set<Date> setDates = new Set<Date>();
    Set<String> setWorkType = new Set<String>();
    Date estimatePlanDate = Date.newInstance(2014,10,31);//condition needs to satisfy for above dates only
    
    //select all the Work types
    for(WPD_Projects__c Proj:trigger.new){
        System.debug(Proj.Estimated_Project_Start_Date__c+'= '+(Proj.Estimated_Project_Start_Date__c >= estimatePlanDate));
        if(Proj.Contract__c != null && Proj.Work_Type__c != null && Proj.Estimated_Project_Start_Date__c >= estimatePlanDate)
            setWorkType.add(Proj.Contract__c);
    }
    Map<String,WPD_Contract__c> mapContract = new Map<String,WPD_Contract__c>();
    if(!setWorkType.isEmpty())
     for(WPD_Contract__c con:[SELECT Id,Work_Type__c,End_Date__c FROM WPD_Contract__c WHERE id IN:setWorkType])
            mapContract.put(con.id,con);
 
    System.debug('mapContract ='+mapContract);
    //condition.    
    for(WPD_Projects__c Proj:trigger.new){
        if(Proj.Estimated_Project_Start_Date__c != null && Proj.Estimated_Project_Start_Date__c >= estimatePlanDate){
            if(Proj.Contract__c!= null && !(Proj.Work_Type__c != null && mapContract.containsKey(Proj.Contract__c) && mapContract.get(Proj.Contract__c) != null
                && Proj.Estimated_Project_Start_Date__c <= mapContract.get(Proj.Contract__c).End_Date__c
                && mapContract.get(Proj.Contract__c).Work_Type__c.ContainsIgnoreCase(Proj.Work_Type__c))){
                    Proj.addError('Work Type/Estimated Project Start Date is not matched for the Contract.');
            }
        }
    }

    //CH01.End
}