Skip to content
This repository was archived by the owner on Jan 10, 2024. It is now read-only.

Include picklistValues in describe result #50

Merged
merged 1 commit into from
Apr 22, 2014
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 22 additions & 1 deletion RemoteTKController.cls
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,26 @@ public class RemoteTKController {
return null;
}

private static List<Object> picklistOptions(Schema.DescribeFieldResult field) {
List<Object> picklistOptions = new List<Object>();
Schema.DisplayType fieldType = field.getType();
if (fieldType != Schema.DisplayType.Picklist &&
fieldType != Schema.DisplayType.MultiPicklist &&
fieldType != Schema.DisplayType.Combobox) {
return picklistOptions;
}
List<Schema.PicklistEntry> picklistValues = field.getPicklistValues();
for (Schema.PicklistEntry picklistValue: picklistValues) {
Map<String, Object> picklistOption = new Map<String, Object>();
picklistOption.put('value', picklistValue.getValue());
picklistOption.put('label', picklistValue.getValue());
picklistOption.put('active', picklistValue.isActive());
picklistOption.put('defaultValue', picklistValue.isDefaultValue());
picklistOptions.add(picklistOption);
}
return picklistOptions;
}

@remoteAction
public static String describe(String objtype) {
// Just enough to make the sample app work!
Expand Down Expand Up @@ -113,7 +133,8 @@ public class RemoteTKController {
if (!references.isEmpty()) {
field.put('referenceTo', references);
}

field.put('picklistValues', picklistOptions(descField));

fields.add(field);
}

Expand Down