Created
November 23, 2015 10:18
-
-
Save atulgupta31/236e03a676918cb2fbca 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
public class vfc_radarSeries { | |
public List<Map<Object,Object>> data = new List<Map<Object,Object>>(); | |
public String acctId {get;set;} | |
public vfc_radarSeries(){ | |
acctId = '0019000000NcZv3'; | |
} | |
public List<Map<Object,Object>> getData() { | |
Set<String> setStrings = new Set<String>{'AnnualRevenue','NumberOfEmployees','NumberofLocations__c'}; | |
List<String> fieldNames = new List<String>(setStrings); | |
String query = 'Select Id,Name,AnnualRevenue,NumberOfEmployees,NumberofLocations__c FROM Account where Id=\'' + acctId + '\' LIMIT 1'; | |
SObject myFieldResults = Database.Query(query); | |
Schema.DescribeSObjectResult R = myFieldResults.getSObjectType().getDescribe(); | |
Map<String, Schema.SObjectField> fieldMap = R.fields.getmap(); | |
//creates a map of labels and api names | |
Map<String,String> labelNameMap = new Map<String,String>(); | |
for(String key : fieldMap.keySet()){ | |
labelNameMap.put(fieldMap.get(key).getDescribe().getName(), fieldMap.get(key).getDescribe().getlabel()); | |
} | |
//creates a map of labels and values | |
for(String f : fieldNames){ | |
String fieldLabel = labelNameMap.get(f); | |
String fieldValue = String.valueOf(myFieldResults.get(f)); | |
Map<Object, Object> m = new Map<Object,Object>(); | |
m.put('field', fieldLabel); | |
m.put('value', fieldValue); | |
data.add(m); | |
} | |
return data; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment