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
Danielle RosenDanielle Rosen 

Trying to query a lookup relationship from non-master object.


I have a field called 'Main Contact,' which is a lookup relationship on my Account object. I am trying to query the Main Contact's email, full name, and phone number, from a button on the Contract object, (custom Conga object.) I've come at this a bunch of different ways, but can't seem to get the data to pull. Here's what I have at the moment: SELECT Main_Contact__r.Email, Main_Contact__r.Name, Main_Contact__r.Phone FROM Account WHERE Id = '{pv0}' Any guidance would be much appreciated! Thank you!  
Raj VakatiRaj Vakati
Try this 
SELECT (Select Id , Email, Name, Phone from Main_Contact__r ),Id FROM Account WHERE Id = '{pv0}'

sharathchandra thukkanisharathchandra thukkani
Your query should work fine but in place of pv0 it should be 18 or 15 digit id.