So, I've got a page where I have a couple of Objects and users can select any of these objects. Based on the selection, a dynamic query gets fired and result records show up. The user can then check whichever records he wants and proceed. For this checking records thing, I've used a wrapper class. However, like I said the object selection and query is dynamic. So in the Wrapper class, I have used GET SET for sObject data type.
This perfectly works until I go to VF page to display the records in a PageBlockSection. Here, fields except ID don't fit in ... The error says something like " XYZ is not the field of sObject".
I know the above explanation is pretty perplexing but I hope you get the point.
I am afraid @digamberlucky but I dont really follow the solution you suggested. I am passing the instance of whichever the object selected to the wrapper class for further processing.
Below is a sample loop. Here the instance is for Case. Initially I had sObject here.
for(Case s : Database.Query(theQ)) { system.debug('THE S:-'+s); wrapperClass wc = new wrapperClass(s); system.debug('THE WC:-'+wc); theResultList.add(wc); }
Hi,
What do you mean by generic Wrapper class for sObject? Could you be please explain it along with your requirement?
Happy to help you!
Regards,
Digamber Prasad
Hello!
So, I've got a page where I have a couple of Objects and users can select any of these objects. Based on the selection, a dynamic query gets fired and result records show up. The user can then check whichever records he wants and proceed. For this checking records thing, I've used a wrapper class. However, like I said the object selection and query is dynamic. So in the Wrapper class, I have used GET SET for sObject data type.
This perfectly works until I go to VF page to display the records in a PageBlockSection. Here, fields except ID don't fit in ... The error says something like " XYZ is not the field of sObject".
I know the above explanation is pretty perplexing but I hope you get the point.
--Kevin
Force.com Certified Developer
Hi,
I can get what you want to achieve through this.
In your wrapper class, why don't you create a string field, which will store ID of your record and probably you can get rid off this issue.
Please let me know if you have any question around this solution.
Happy to help you!
Regards,
Digamber Prasad
I am afraid @digamberlucky but I dont really follow the solution you suggested. I am passing the instance of whichever the object selected to the wrapper class for further processing.
Below is a sample loop. Here the instance is for Case. Initially I had sObject here.