You need to sign in to do that
Don't have an account?
Tracy Bingham
My first ever SOQL query? Works until I try and get the user name.
Where am I going wrong? this works if I only ask for the Owner ID but as soon as I try and get the user name I get an unknown error parsing query.
SELECT OwnerId, User.Name FROM Event, StartDateTime,Subject,Hotel__c,Activity__c,Notes__c, Done__c,Completed__c,Cancelled__c,Postponed__c
FROM Event
WHERE StartDateTime = LAST_MONTH
Any help much appreciated.
Thanks
SELECT OwnerId, User.Name FROM Event, StartDateTime,Subject,Hotel__c,Activity__c,Notes__c, Done__c,Completed__c,Cancelled__c,Postponed__c
FROM Event
WHERE StartDateTime = LAST_MONTH
Any help much appreciated.
Thanks
The User.Name field is not related to the Event object. You need to join the Event object with the User object using a relationship field, such as OwnerId.
You have multiple FROM statements in your query, which is not allowed. You can only have one FROM statement in a SOQL query, and it should specify the object you are querying.
The list of fields after the FROM statement should not include StartDateTime, Subject, Hotel__c, etc. Those fields should be included in the list of fields after the SELECT statement.
Here is a corrected version of your SOQL query:
This query selects the OwnerId and Owner.Name fields from the Event object, and filters the results to show only events that have a StartDateTime value in the last month.
All Answers
User field is not available in event object, you can remove the User.Name from query and try.
Refer the below object reference link
https://developer.salesforce.com/docs/atlas.en-us.object_reference.meta/object_reference/sforce_api_objects_event.htm
If this helps, Please mark it as best answer.
Thanks!!
The User.Name field is not related to the Event object. You need to join the Event object with the User object using a relationship field, such as OwnerId.
You have multiple FROM statements in your query, which is not allowed. You can only have one FROM statement in a SOQL query, and it should specify the object you are querying.
The list of fields after the FROM statement should not include StartDateTime, Subject, Hotel__c, etc. Those fields should be included in the list of fields after the SELECT statement.
Here is a corrected version of your SOQL query:
This query selects the OwnerId and Owner.Name fields from the Event object, and filters the results to show only events that have a StartDateTime value in the last month.
In this query, the Owner.Name field is related to the Event object through the OwnerId field, which is a lookup relationship to the User object. This allows you to retrieve both the OwnerId and the Owner.Name fields in the same query