You need to sign in to do that
Don't have an account?
Prince_sfdc
getvalue() vs getLabel() in PickListEntry Class
what is the difference between the getValue() and getLabel() in PickListEntry Class, please explain with an example for each.
function readOnly(count){ }
You need to sign in to do that
Don't have an account?
One is Value and the other one is Label.
getValue() -> gives you assigned value of a picklist entry
getLabel() -> gives you whats visible to the end user
In SFDC object fields, value and label components of Picklist entries are same. set that aside. (Fields like Country, Province, Opportunity StageName etc)
The real significance IMO of value,label pair of picklist comes in VF/Apex.
Suppose you have a picklist in VF to display All existing Contacts. There can be more than one Contact Persons having same name. So when a user selects a entry from picklist, how would you know which record to handle?
This is where it all starts making sense. What developers do is that they store contact id as value and contact name as Label for each picklist entry.
Now, an end user sees Labels ie Contact Name, but when an entry is selected, its the value of the selected entry that's stored in Apex. which can be used to uniquely identified the contact record.
More info here:
https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_class_Schema_PicklistEntry.htm
Mark it as Best Answer, if it helps.
All Answers
One is Value and the other one is Label.
getValue() -> gives you assigned value of a picklist entry
getLabel() -> gives you whats visible to the end user
In SFDC object fields, value and label components of Picklist entries are same. set that aside. (Fields like Country, Province, Opportunity StageName etc)
The real significance IMO of value,label pair of picklist comes in VF/Apex.
Suppose you have a picklist in VF to display All existing Contacts. There can be more than one Contact Persons having same name. So when a user selects a entry from picklist, how would you know which record to handle?
This is where it all starts making sense. What developers do is that they store contact id as value and contact name as Label for each picklist entry.
Now, an end user sees Labels ie Contact Name, but when an entry is selected, its the value of the selected entry that's stored in Apex. which can be used to uniquely identified the contact record.
More info here:
https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_class_Schema_PicklistEntry.htm
Mark it as Best Answer, if it helps.