Global Picklist or Picklist Value Set is an Universal Picklist Values, which can be applied to any custom picklist fields that you create both on standard and custom objects.
Lets take an example, I have an object called “Student” and “Student Application” in these two object I have to create a picklist field called “Language”. So, here I’ve created a “Picklist Value Set” and used it on both object “Student Application”.
Click Setup || App Setup || Create || Picklist Value Set || Click ‘New’
Create “Language” Picklist Value Set:
Create “Language” Picklist from Picklist Value Set in “Student” and “Student Application” object:
Check “Language” Picklist Value Set, where it is used:
Note: You can have up to 500 picklist global value sets in an org. Each global value set, or restricted picklist, can contain a mix of 1,000 active and inactive values. Unrestricted picklists can have up to 1,000 active values. There’s no limit on the number of custom picklists that use global picklist value sets.
Picklist Value Set Considerations:
Validation rules are still defined at the field level, and are not part of the Picklist Value Set definition. This means, you can have the Business Unit picklist field on Account to respect a validation rule; and the same field on the Contact object not.
It is possible to create a mutli-select picklist field using a Picklist Value Set definition. However, in such cases the “replace” functionality available on regular picklist fields are not available.
Also, a picklist field created based on a Picklist Value Set cannot be used as a dependent picklist. It can still be used as a controlling picklist field. This is a known and documented limitation.
public with sharing class Sample
{
public string selectedValue {get; set;}
public List<SelectOption> industry {get; set;}
public void getIndustry()
{
Schema.DescribeFieldResult industryDescription = Account.Industry.getDescribe();
industry = new List<SelectOption>();
for (Schema.Picklistentry pl : industryDescription.getPicklistValues())
{
industry.add(new SelectOption(pl.getValue(),pl.getLabel()));
}
}
public void checkValue()
{
System.debug('Selected Industry Type - ' + selectedValue);
}
}
String defaultLeadStatus = '';
//Get Lead object Status field description
Schema.DescribeFieldResult fieldDesc = Schema.Lead.Status.getDescribe();
//Loop on Status picklist field values
for (Schema.Picklistentry picklistEntry: fieldDesc.getPicklistValues()) {
//Check if picklist value is default
if (picklistEntry.isDefaultValue()) {
defaultLeadStatus = picklistEntry.getValue();
break;
}
}
This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish.AcceptReject