function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
nimbusprojectnimbusproject 

Something similar to GET() in VisualForce

I need to output the results of a generic SOQL query made as follows that assigns a set of results to: List<sObject> currentList as follows:

 

 

List<sObject> currentList = new List<sObject>(); for(String obj_type : selectedObjectsLabels) { currentList = Database.query('select ' + relatedFields + ' from ' + obj_type); finalObjects.addAll(currentList); }

 

 Currently, the output is organized using a JSON object, but this will not work with renderas="PDF" as it requires JScript.

 

 

 

<apex:page controller="QueryFilterController" showHeader="false" renderAs="pdf"> <apex:form > <h3>Report Results</h3> <br /> <apex:dataList value="{!currentList}" var="reports"> <apex:repeat value="{!reports}" var="report">{!report}</apex:repeat> </apex:dataList> </apex:form> </apex:page>

 

 Any thoughts?

 

 

WesNolte__cWesNolte__c

Hey

 

This is a quite big task. There used to be an article in the wiki about it(cannot find the darn thing).

 

Since parameters can't be passed to methods, like you're looking to do with the get() method you'll need to wrap the SObject with a generic class, and then use dynamic apex to fetch the list of fields for that object. You would then need to nest your repeats, one for the list of SObject wrappers, and another repeat for the list of Sobject wrapper fields.

 

 

public class SObjectWrapper{public SObject obj{get;set;}public SObjectWrapper(SObject s)obj = s;}/* This is pseudo code */public List<fields> getFields(){ return ...}}

 

 There are a few article you'll need to read:

 

http://www.salesforce.com/us/developer/docs/apexcode/index_Left.htm#StartTopic=Content%2Fapex_dynamic.htm|SkinName=webhelphttp://www.salesforce.com/us/developer/docs/apexcode/index_Left.htm#StartTopic=Content/apex_methods_system_fields_describe.htm?SearchType=Stem

 

Not a simple solution, but definitely an interesting one. Good luck.

 

Wes 

 

p999_dfsp999_dfs

Did you get any luck to output the results of a generic SOQL query i nthe Visual force page.