Advertisement
Guest User

Untitled

a guest
Jul 27th, 2016
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.67 KB | None | 0 0
  1. <apex:pageBlockSection title="Results" collapsible="false">
  2. <apex:pageBlockTable value="{!queryResultsList}" var="prod2">
  3. <apex:repeat value="{!fieldAPINames}" var="fieldAPIName">
  4. <apex:column value="{!prod2.[fieldAPIName]}"/>
  5. </apex:repeat>
  6. <!--
  7. <apex:column value="{!prod2.Name}"/>
  8. <apex:column value="{!prod2.Description}"/>
  9. <apex:column value="{!prod2.IsActive}"/>
  10. <apex:column value="{!prod2.ProductCode}"/>
  11. <apex:column value="{!prod2.Family}"/>
  12. -->
  13. </apex:pageBlockTable>
  14. </apex:pageBlockSection>
  15.  
  16. public class ProductCatalogPageController {
  17. public List<Product2> queryResultsList{get;set;}
  18. public String query{get;set;}
  19. public String strOfStuff{get;set;}
  20. public Map<String, Schema.SObjectField> fieldAPINames{get;set;}
  21.  
  22. public PageReference testAction(){
  23. String SobjectApiName = 'Product2';
  24.  
  25. Map<String, Schema.SObjectType> schemaMap = Schema.getGlobalDescribe();
  26. Map<String, Schema.SObjectField> fieldMap = schemaMap.get(SobjectApiName).getDescribe().fields.getMap();
  27.  
  28. String csvFields = '';
  29. for(String fieldName : fieldMap.keySet()){
  30. if(csvFields == null || csvFields == ''){
  31. csvFields = fieldName;
  32. }else{
  33. csvFields = csvFields + ', ' + fieldName;
  34. }
  35. }
  36. query = 'select ' + csvFields + ' from ' + SobjectApiName;
  37. queryResultsList = Database.query(query);
  38.  
  39. strOfStuff = 'Stuff goes here';
  40.  
  41. return null;
  42. }
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement