0

Is it possible to write a SOQL query to retrieve the Contacts associated to a Campaign as Campaign Members and then get a number of records related to those Contacts?

This will return a list of the Campaignmember Contacts:

Select id, firstname, lastname from Contact where id in
(Select contactid from Campaignmember where campaignid = '701000000000000')

But I also need the Notes, Tasks and Opportunities records associated to those Contacts. I'm doing this to populate a Conga template so I can't use APEX or a multi-step process.

The post identified as a duplicate of mine Conga - Multiple Queries is solved by passing a single parent id to multiple separate queries. Generally this is done to show a single Conga document with information about the parent and related lists. (ex. Account info with a list of related Contacts, Opportunities, Calls Logged). I'm trying to take my first query which returns multiple Contacts from a Campaign Member list and pass those Id's to different queries to get records related to the Contacts. Instead of a document with a single Contact and related Opportunities, Tasks, etc., I would have Contact1 and its related records, Contact2 and its related records, Contact2 and its related records, etc.

  • 1
    You'll need to make multiple queries. See this answer of mine for details on how to do that. – battery.cord Jul 17 '17 at 19:50
  • Thanks for your responses but I know I need to use multiple queries. What I'm trying to do is join the above query which returns my ContactId's with queries that return records related to those contacts. – Aiden Martin Jul 17 '17 at 21:28
  • If you edit this question, it will be put into a re-open queue, where users can vote on if your question should be opened. It seems like what your asking is how to filter some number of conga queries based on the result of another query, from your conga url? – battery.cord Jul 18 '17 at 13:07
0

You can try the following:

SELECT Id, Name FROM Contact WHERE Id IN (SELECT ContactId FROM Campaign WHERE Id = :campId) AND Id IN (SELECT ContactId FROM Opportunity WHERE Id = :oppId)

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.