You need to sign in to do that
Don't have an account?
Need Help on SOQL
Hi,
I need help on SOQL.
My requirment is like this....
I have a added a Contact section in Opportunity (Created as Custom Object, and fileds are "Master-Detail Relationship" type. Where the Master Object is Contact, Opportunity).
I can create new Opportunity and then i can add some Contact at this Contact Section of Opportunity.
Now, how can i get the details of this Contacts using Query.
Ex:
Query: Select o.Id, o.Name from Opportunity o
in this query i can get the Id and Name of Opportunity, but how can i get the Contact information which i added in the new Contact section??
I am not able to see anything related to this new Object in Apex Explorer....
Thanks for any help....
Thanks
skumar
The __r fields are key for you -- those are your relationships. You need them.
If I were you I'd start by reading these docs, particularly the articles about relationship queries. Search that in the index.
You'll probably want to query on your junction object, so something like (for example)
Select j.Id, j.Contact__r.Name, j.Opportunity__r.Name from OppContact__c j Where Contact__.Name='Joe Smith'
All Answers
Go to Tools->Options in Apex Explorer and change your endpoint to 15.0.
Also, you've just reinvented something that's already there: OpportunityContactRole.
Hi,
Thanks for your reply.
Now i could see that Junction Object and all the related fields in Apex Explorer.
But still i didn't get how to write a Query to get the result what i wanted.
I want to Query the Name of Opportunity and the Contact Details (First Name, Email, ect) which is diplsying in the Contact section under Opportunity.
And you are correct, I did somthing similar to OpportunityContactRole. But this will help me to do the same thing for Other Objects (Ex: Asset-Contact)
Let me explain in detail....
I have created One custom Object "OppContacts" and added 2 fields of type "Master-Detail Relationship"
Fileds are - Opportunity and Contact Object
and then added this object to Opportunity page by edditting the Opportunity page Layout (included FirstName, Email, Type fields from the Contact). So i can create Opportunity and then i can addd Contacts wich is already created.
But how can i write a Query so that i can get - Opportunity Id, Name, Contact FirstName, Email.
How can i relate these Objects? What is the importance of '__r' field here?
I don't have much experience on this SOQL and Salseforce objects.
Hope you have solution for this....
Thanks again.....
Anybody have any solution for this..please.....
The __r fields are key for you -- those are your relationships. You need them.
If I were you I'd start by reading these docs, particularly the articles about relationship queries. Search that in the index.
You'll probably want to query on your junction object, so something like (for example)
Select j.Id, j.Contact__r.Name, j.Opportunity__r.Name from OppContact__c j Where Contact__.Name='Joe Smith'
Thanks.....
Now i can move forward and can do some changes as per my requirment...