You need to sign in to do that
Don't have an account?
Perform an additional SOQL query
Below is an extension that brings back contact roles that are related to an account and have a type = Board Member. The extension is called from a visualforce page which is triggered by a button on an account page the results are displayed in a table on the page - this bit works well.:smileyhappy:
For the contacts retrieved I need to perform an additional query to see what other board member contact roles they have and display them in a separate table.
Example
So query 1 would bring back Joe Bloggs who is a board member of ABC Co. And Jane Doe who is a board member of ABC Co.
I need query 2 to use Joe and Janes contact ID and search to find any contact roles that have a type of board member and are not ABC Co.
Not sure how to join these statements, any suggestions welcome - thanks in advance.
public with sharing class AccountListExtension { private final Account acct; public AccountListExtension(ApexPages.StandardController controller) { this.acct = (Account)controller.getRecord(); } public List<Contact_Role__c> getBoardmembers(){ List<Contact_Role__c> listBd = [Select c.id, c.contact__r.name, c.title__c, c.State__c, c.primary_account__c from Contact_Role__c c where c.account__r.Id = :this.acct.Id and c.Contact_Role__c='Board Member']; return listBd; }}
You can find SOQL documentation here -http://www.salesforce.com/us/developer/docs/api/index_Left.htm#StartTopic=Content%2Fsforce_api_calls_soql.htm|SkinName=webhelp
To understand the basic Apex language constructs, start with the first few chapters of this reference documentation.
http://www.salesforce.com/us/developer/docs/apexcode/index.htm
Hope this helps.