Skip to main content
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
5 risposte
  1. 3 feb 2023, 19:51
    I see few issues 

    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:

    SELECT OwnerId, Owner.Name, StartDateTime, Subject, Hotel_c, Activityc, Notesc, Donec, Completedc, Cancelledc, Postponed_c

    FROM Event

    WHERE StartDateTime = LAST_MONTH

    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.