Created
November 12, 2018 12:05
-
-
Save simpluslabs/42f3469d2e2304da5ec2d5be00355fdf to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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