You need to sign in to do that
Don't have an account?
Diane Royer
SOQL Query Giving Error Message
I'm trying to write an SOQL query that will pull information from the Contact object and the Event Object. When I tried to use Event as the child object, I received an error message that Event could not be the child, so I switched the query around to this:
SELECT Event.whoid, Event.StartDateTime, Event.Subject, (select contact.id, contact.firstname, contact.lastname, contact.MailingStreet, contact.MailingCity, contact.MailingState, contact.MailingPostalCode from Contact)
from Event
Where Event.whoid = '0034M000020OgliQAC'
Unfortunately, it still isn't working. It tells me "Didn't understand relationship 'Contact' in FROM part of query call.". What am I doing wrong?
In SQL, the query would look like this:
Select Event.Whoid, Event.StartDateTime, Event.Subject, Contact.firstname, contact.lastname, contact.MailingStreet, Contact.MailingCity, contact.MailingState, contact.MailingPostalCode
from Event
Join Contact on Event.Whoid = Contact.id
where event.whoid = '0034M000020OgliQAC'
Any assistance would be greatly appreciated.
SELECT Event.whoid, Event.StartDateTime, Event.Subject, (select contact.id, contact.firstname, contact.lastname, contact.MailingStreet, contact.MailingCity, contact.MailingState, contact.MailingPostalCode from Contact)
from Event
Where Event.whoid = '0034M000020OgliQAC'
Unfortunately, it still isn't working. It tells me "Didn't understand relationship 'Contact' in FROM part of query call.". What am I doing wrong?
In SQL, the query would look like this:
Select Event.Whoid, Event.StartDateTime, Event.Subject, Contact.firstname, contact.lastname, contact.MailingStreet, Contact.MailingCity, contact.MailingState, contact.MailingPostalCode
from Event
Join Contact on Event.Whoid = Contact.id
where event.whoid = '0034M000020OgliQAC'
Any assistance would be greatly appreciated.
All Answers
Event and Task are special kind of SObject, they are not child to Contact. Also the WhoId is either Lead or Contact so Salesforce has introduce TYPEOF feature in SOQL that can help you
https://developer.salesforce.com/docs/atlas.en-us.soql_sosl.meta/soql_sosl/sforce_api_calls_soql_select_typeof.htm
This is a quick SOQL for your help but I would like to see how you wanted to use it because so provide you with complete solution I hope this will help you moving forward
When I try to run the query you sent, I get an "Unknown error parsing query".
I'm trying to get an SOQL query set up to use in a Conga Mail Merge. Eventually, I want to get these fields populated in a template letter thanking contacts for coming for a visit.
If you are trying to use this query in an apex class or anywhere please make sure the api version is either 46 or greater as it is supported only there.
If you can share some part of your code, will definitely help you further.
Work for me good
Were you able to get my last update? Was this helpful?