0

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

select 
    Id,
    Subject, 
    Status, 
    OwnerId,
    Owner.Name,
    Owner.IsActive
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.

Visualforce

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

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.

3
  • What have you tried so far? Where abouts are you stuck? Are you trying to do it all in SOQL?
    – BarCotter
    Commented 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>> Commented 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
    Commented Apr 12, 2015 at 22:05

2 Answers 2

-1

Perform SOQL and create Map by results

1
-1

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

1
  • Can you please provide more details or an example of how you solved the problem? Commented 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 .