Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
global class dynamicPicklistDesignApx extends VisualEditor.DynamicPickList
{
VisualEditor.DesignTimePageContext context;
global dynamicPicklistDesignApx(VisualEditor.DesignTimePageContext context) {
this.context = context;
}
global override VisualEditor.DataRow getDefaultValue(){
return null;
}
global override VisualEditor.DynamicPickListRows getValues() {
String currentPageObjectName = context.entityName;
String fieldName = 'Industry';
VisualEditor.DynamicPickListRows picklistValues = new VisualEditor.DynamicPickListRows();
Map<String, Schema.SObjectField> currPageObjectfieldsMap = Schema.getGlobalDescribe().get(currentPageObjectName).getDescribe().fields.getMap();
for(Schema.SObjectField field : currPageObjectfieldsMap.values())
{
Schema.DescribeFieldResult descField = field.getDescribe();
if(String.ValueOf(descField.type)=='PICKLIST' && descField.getName()==fieldName)
{
List<Schema.PicklistEntry> valuesList = new List<Schema.PicklistEntry>();
valuesList = descField.getPicklistValues();
for(Schema.PicklistEntry value : valuesList)
{
VisualEditor.DataRow dataRow = new VisualEditor.DataRow(value.getLabel(), value.getValue());
picklistValues.addRow(dataRow);
}
break;
}
}
return picklistValues;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.