You need to sign in to do that
Don't have an account?

Find all Instances of an Objects.
Hi guys,
I developed an Visualforce Page, which shows all Objects that are available. Now I want to find all Instances of one Particular Object.
I tried some stuff like this, but can't verify if it works, cause i have no idea how i could get a String with the Name out of the SObject.
Do I need a wrapperclass for showing the Results in a table?
String queryString = 'SELECT Id, Name, FROM '+ paramFromVF; // paramFromVF is the name of the Object
List<sObject> L = Database.query(queryString);
Anyway, I think this is quite a beginner question, but as I am a beginner this is tough for me at the moment.
Thanks a lot for your help.
Hi MX,
I think you are trying to use Dynamic soql query.
//This is your code
String queryString = 'SELECT Id, Name, FROM '+ paramFromVF;
Use following code:
// Remove comma(,) after Name.
String queryString = 'SELECT Id, Name FROM '+ paramFromVF;
List<sObject> instancelist = Database.query(queryString);
No, you don't need to use wrapperclass.
You can display results as a table on VF page using pageblocktable.
if this is the solution for your issues then please mark as a solution and it helps other for similar issues.
All Answers
Hi MX,
I think you are trying to use Dynamic soql query.
//This is your code
String queryString = 'SELECT Id, Name, FROM '+ paramFromVF;
Use following code:
// Remove comma(,) after Name.
String queryString = 'SELECT Id, Name FROM '+ paramFromVF;
List<sObject> instancelist = Database.query(queryString);
No, you don't need to use wrapperclass.
You can display results as a table on VF page using pageblocktable.
if this is the solution for your issues then please mark as a solution and it helps other for similar issues.
Thanks a lot, what a stupid mistake.