-1
 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.

0

1 Answer 1

1

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

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

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