-1

This question already has an answer here:

 if(!ad.Street__c.contains('XXYYZZ'))
  { 
    ForNewRecord.add(ad);
  }

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.

marked as duplicate by Adrian Larson, Community May 11 '16 at 2:54

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

1

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.