You need to sign in to do that
Don't have an account?
shabbu
How to fetch count of contacts for picklists value in account
I need to create a button on account, When clicked, this button should show a table which lists all status types and counts of contacts of each status type for that account. Status is picklist field which is having 4 options.
You can use an SOQL like this
[Select Status, count(Id) from Account.Contacts group by Status],
This will return AggregateResult[], Loop thru this and store it in a list which can displayed on the VF page using datatable or pageblocktable..
but problem in soql query
acct=[select Status__c,count(Id) from Account.Contacts group by Status__c];
acct=[select name,[select Status__c,count(Id) from Contacts group by Status__c] from Accounts];
i tried by using these both
can you plz help me in this.........
i am going to create a button in account object for that button i am going to write vf and controller......
controller:
public with sharing class contstatus {
public contstatus(ApexPages.StandardController controller) {
}
public list<Account> acct{get; set;}
public void countsearch(){
acct=[select Status__c,count(Id) from Account.Contacts group by Status__c];
}
}
in VF Page by using page block table i will display the count of contact for status field on account object