You need to sign in to do that
Don't have an account?
Arun Deepan LJ
Custom Label in Picklist
Hi,
How custom labels can be used in the picklist. While creating a picklist field, can we directly refer the values from the Custom labels?. I know about the translation settings, but what I want, I don't want the picklist values to be hardcoded, since the picklist value is referred in Apex coding in multiple place. And Hence, a change in Picklist means, I have change every where in the code. What is the best solution to such scenario?
How custom labels can be used in the picklist. While creating a picklist field, can we directly refer the values from the Custom labels?. I know about the translation settings, but what I want, I don't want the picklist values to be hardcoded, since the picklist value is referred in Apex coding in multiple place. And Hence, a change in Picklist means, I have change every where in the code. What is the best solution to such scenario?
https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_dynamic_soql.htm
You can store the custom label value in any variable and use that in where condition as
All Answers
Thats a quite good option. But I wanted is, Generally we use picklist values in many SOQL queries as "where" condition to retrieve the records, such [SELECT id, Name from custom_object__c where custom_picklit__c = 'Option 1' ]. In such scenario, I don't want to hardcode the value as 'Option 1'. That must admin configurable, so that, any change in that pick list value in future, does not require to edit the Apex Code.
https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_dynamic_soql.htm
You can store the custom label value in any variable and use that in where condition as
Thank you for your answer. I am aware of using the Dynamic SOQL. In this case, when a pick list value is changing. Need to change in two places.
1 in pick list field itself and
2 in the custom Label
is that right
https://help.salesforce.com/HTViewHelpDoc?id=fields_creating_global_picklists.htm&language=en_US