function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
hashir kphashir kp 

how can we see related opportunities of contact which is added in campaign member in campaign object?

Hi, i would like to see opportunities if any for conatcs added as campaign memeber in campaign object. how can we achieve this? if we are using trigger how to achieve this requirement
mukesh guptamukesh gupta
Hi Hasih,

Please follow below query
select id, name, (select id,FirstRespondedDate,Status,CreatedDate,ContactId from CampaignMembers where ContactId IN (SELECT ContactId FROM OpportunityContactRole)),(select id,name,closeDate from Opportunities) from campaign where Id in (SELECT CampaignId FROM Opportunity WHERE StageName = 'Closed Won' AND CloseDate = THIS_YEAR)

if you need any assistanse, Please let me know!!

Kindly mark my solution as the best answer if it helps you.

Thanks
Mukesh 
hashir kphashir kp
@mukesh gupta
thank you for the reply
actually i need to achieve this using a trigger can you help me with that. it will be useful for me