0

I need to Count Number of Activities of Account and place that Number of activities in visualforce page using table.

I have already created a MAP

CONTROLLER

public Map<Integer, Account> getabc()

{

for( Account accountObj : [SELECT (SELECT Id FROM ActivityHistories) FROM Account where Referring_Contact__c in : contactIdList])

{

if(mapActivityHistoryCountToAccount.containsKey(accountObj.ActivityHistories.size()))

{

mapActivityHistoryCountToAccount.put(accountObj.ActivityHistories.size(), accountObj);

}

}

return mapActivityHistoryCountToAccount;

}

VF PAGE

<apex:pageblocktable value="{!abc}" var="item1">

                            <apex:column headerValue="Number of Activities">
                                <apex:outputText value="{!abc[item1].size}">
                                </apex:outputText>
                            </apex:column>
</apex:pageblocktable>

Please somebody Help me to resolve this

  • Can you share more detail of what you tried so far, the VF page and controller/extension for example would be helpful. – Girbot Jun 30 '15 at 9:55
  • Please see my controller and vf page. if it is not correct then let me know what mistake i have made. – Nihar Jun 30 '15 at 10:09
0

I would suggest the simpler approach of returning the raw data to the page:

public List<Account> getAbc() {
    return [
            select Name, (select Id from ActivityHistories)
            from Account
            where Referring_Contact__c in :contactIdList
            order by Name
            limit 1000
            ];
}

and then just referencing the child list size in the page:

<apex:pageblocktable value="{!abc}" var="item">
    <apex:column value="{!item.Name}"/>
    <apex:column headerValue="Number of Activities">
        <apex:outputText value="{!item.ActivityHistories.size}"/>
    </apex:column>
</apex:pageblocktable>

(The above is untested.)

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.