I want to fetch the list of active User and their list of Task records.

Following Query works for me to fetch all Task records with an active User

from Task 
where OwnerId in (select Id from User where isActive = true)

Thanks to @BarCotter.

Now, I want Total and Completed counts of Task records for each User separately and print the results in Visualforce.


    <apex:repeat value={!listUser}>
          <input type="text" class="myJSClass" value="{!taskPercentage}"/> 

Apex Method

public Double getTaskPercentage(){
    // *** HERE I want to calculate the Tasks Percentage like
    Double tpercent = (taskcompleted * 100)/totaltask;
    return tpercent;

I am thinking of using apex:actionFunction but I am little confused today with the basics.

  • What have you tried so far? Where abouts are you stuck? Are you trying to do it all in SOQL?
    – BarCotter
    Apr 10, 2015 at 9:46
  • I want List of all task for each user, Like Contacts of Account i.e. Map<accountid, List<contact>> Apr 10, 2015 at 9:48
  • 2
    You are going to need to take the results of your SOQL and build a list of inner class objects - where each object is for a single user and its Tasks. That inner class object can then have getter methods that do useful work - like % completion, totals, etc.
    – cropredy
    Apr 12, 2015 at 22:05

2 Answers 2


Perform SOQL and create Map by results


Using Wrapper Class I did solved my problem with very ease.

  • Can you please provide more details or an example of how you solved the problem? Apr 13, 2015 at 6:38

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .