cancel
Showing results for 
Search instead for 
Did you mean: 

Obtaining Data Through a Junction Object Using SOQL

Topic

How to use a SOQL relationship to obtain data through a Salesforce Junction Object. This is also known as replication through a lookup.

Instructions

1. Create a new relationship on your Document Package
2. Change the "Type" to "SOQL"
3. Give the relationship an alias. Be sure it is unique and that it does not match the naming convention of any existing objects or fields in your Salesforce Org.
4. Paste the SOQL Query in the "SOQL" box
5. The example below will pull in all Opportunity Contact Roles:

Primary Object: Opportunity ( Opportunity )

Related List Junction Object: Contact Roles (  OpportunityContactRole )

Object In Junction Object: Contacts (  Contact )


SELECT Contact.name FROM OpportunityContactRole WHERE Opportunity.Id = '<<Opportunity_ID>>'



SELECT lookup_(Object in Junction)api_name.field FROM junction_object_api_name WHERE main_object_api_name.id = '<<main_object_record_id_tag>>'


For custom objects, be sure to append __r at the end for dot notated fields.

SELECT lookup_(Object in Junction)api_name__r.field FROM junction_object_api_name WHERE main_object_api_name__r.id = '<<main_object_record_id_tag>>'


Related Links


Labels: (2)
Version history
Revision #:
36 of 36
Last update:
‎11-19-2018 12:47 PM
Updated by: