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
k sfdck sfdc 

how to display contact related opportunity fields ?


Hi,
         Through URL i was get Contactid,using this contactid how to get related opportunity fields?

please help me.......
Ruwantha  LankathilakaRuwantha Lankathilaka
list<Opportunity> Opportunitylist  = [Select (Select OpportunityId From OpportunityContactRoles) From Opportunity where id in  (Select OpportunityId From OpportunityContactRole where ContactId != 'contact_id_from_url')];
You can use the above query to get the opportunity records. Add any opportunity fields you want to retreive. Replace the contact_id_from_url with parsed value
Ramu_SFDCRamu_SFDC
As contact will be a parent to Opportunity, there will be many Opportunity records related to Contact. You would need to set this id to a temporary id variable and then query to get all the related opportunity records.
NaveenReddyNaveenReddy
Hi,

Try below query.

SELECT Id , name FROM   Opportunity WHERE  AccountId IN (SELECT AccountId from Contact WHERE Id = 'selectedConId'

Regards,
Naveen
http://www.autorabit.com