+ Start a Discussion
Jean Grey 10Jean Grey 10 

Display user's daily sales in apex datatable (Visualforce)

I have an apex datatable returning some User fields from a list in my apex class. I would like to include a column "This Month's Sales" which would return the total $ of opps closed won this month. I can run the SOQL in my class but I'm not sure how to get the correct result per user into the table, i.e. how to put it into the correct row and column in my table. Can I attach this $amount to each user without creating a custom field? 
Best Answer chosen by Jean Grey 10
Steven NsubugaSteven Nsubuga
Here are a couple of examples:
  • https://webkul.com/blog/write-wrapper-class-apex/
  • https://www.minddigital.com/what-is-wrapper-class-and-how-to-use-it-in-salesforce/
  • https://cloudtechnzly.blogspot.ug/2017/08/wrapper-class-examples-in-salesforce.html
Each of those is a complete example. Wrapper classes are typically used to show additional columns in tables of sobjects. The additional columns are usually derived columns that do not naturally exist on the sobjects displayed. This is just what you are looking for so I am sure this will be of use to you.

All Answers

Steven NsubugaSteven Nsubuga
You can create a Wrapper class in your visualforce page to display the user and the additional information. 
Jean Grey 10Jean Grey 10
Thanks Steven, can you point me in the direction of a good example of this?
Steven NsubugaSteven Nsubuga
Here are a couple of examples:
  • https://webkul.com/blog/write-wrapper-class-apex/
  • https://www.minddigital.com/what-is-wrapper-class-and-how-to-use-it-in-salesforce/
  • https://cloudtechnzly.blogspot.ug/2017/08/wrapper-class-examples-in-salesforce.html
Each of those is a complete example. Wrapper classes are typically used to show additional columns in tables of sobjects. The additional columns are usually derived columns that do not naturally exist on the sobjects displayed. This is just what you are looking for so I am sure this will be of use to you.
This was selected as the best answer