I have this piece of code in my class. Where XXYYZZ is a value which can be changed any time. I dont want to hard code in the Class. How can i use Custom Label here.


You should add a null check, and use the System.Label namespace:

ad.Street__c != null && ad.Street__c.contains(Label.XXYYZZ)
  • 1
    Will it be like this?? if(ad.Street__c != null && ad.Street__c.contains(System.Label.something)) { ForNewRecord.add(ad); } – Samuel Jackson May 11 '16 at 2:37
  • 1
    @Siva Yep just like that. Fyi you can drop System from System.Label. – Adrian Larson May 11 '16 at 2:43

Not the answer you're looking for? Browse other questions tagged or ask your own question.