Skip to content

Instantly share code, notes, and snippets.

@msrivastav13
Created February 19, 2018 18:14
Show Gist options
  • Save msrivastav13/311031d05639df8f9e6796982c2d5190 to your computer and use it in GitHub Desktop.
Save msrivastav13/311031d05639df8f9e6796982c2d5190 to your computer and use it in GitHub Desktop.
Gets the Field Picklist labels and values from the Object Metadata
global class CommunityBuilderPickListUtil extends VisualEditor.DynamicPickList{
global override VisualEditor.DataRow getDefaultValue(){
VisualEditor.DataRow defaultValue = new VisualEditor.DataRow('Product Family', 'Product Family');
return defaultValue;
}
global override VisualEditor.DynamicPickListRows getValues() {
VisualEditor.DynamicPickListRows myValues = new VisualEditor.DynamicPickListRows();
Schema.DescribeFieldResult fieldResult = Product2.Family.getDescribe();
List<Schema.PicklistEntry> ple = fieldResult.getPicklistValues();
for( Schema.PicklistEntry f : ple){
VisualEditor.DataRow value = new VisualEditor.DataRow(f.getLabel(),f.getValue());
myValues.addRow(value);
}
return myValues;
}
}
<design:component>
<design:attribute name="property1" datasource="apex://CommunityBuilderPickListUtil"/>
</design:component>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment