0

have the below statements using some hard coded strings and I want to make them use as custom labels. So how can I make these statements to use the Custom Labels I created ? custom label:- value A,B,C

else if((caseList[i].gp == 'A' || caseList[i].gp == 'B' || caseList[i].gp == 'C') && (caseList[i+1].gp == 'A' || caseList[i+1].gp == 'B' || caseList[i+1].gp == 'C'))
4
  • create a custom label with value 'A' and name "Avalue". use (eg) if(caseList[i].gp==Lable.Avalue
    – uma451
    Commented May 26, 2016 at 6:23
  • what is not working. You are getting any error? Also this is working with static values? Commented May 26, 2016 at 6:45
  • yes thers a value assets/contact(for eg:-A)it is throwing an error
    – user31877
    Commented May 26, 2016 at 6:51
  • Can you provide more details. as it is hard to give any solution using info provided. Commented May 26, 2016 at 7:49

2 Answers 2

0

You can use them like

System.Label.A, System.Label.B, System.Label.C

More details you can check here Custom label in Apex.

First create three separate labels. then do something like

else if((caseList[i].gp == System.Label.A || caseList[i].gp == System.Label.B || caseList[i].gp == System.Label.C) && (caseList[i+1].gp == System.Label.A || caseList[i+1].gp == System.Label.B || caseList[i+1].gp == System.Label.C))
4
  • i have only one custom label and the values A,B,C are in that label how can i use it?
    – user31877
    Commented May 26, 2016 at 6:25
  • you create three custom labels for A ,B and C
    – uma451
    Commented May 26, 2016 at 6:30
  • Tushar thanks but its not working
    – user31877
    Commented May 26, 2016 at 6:37
  • Btw, you can use Labels without System keyword, just Label.yourLabelName in apex. Commented May 26, 2016 at 8:21
0

Create a custom Label. Value =A name="Avalue" Value =B name="Bvalue" Value =C name="Cvalue"

Eg;

else if((caseList[i].gp == Label.Avalue || caseList[i].gp == Label.Bvalue ||    caseList[i].gp == Label.Cvalue) && (caseList[i+1].gp ==Label.Avalue || caseList[i+1].gp == Label.Bvalue || caseList[i+1].gp == Label.Cvalue))

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .