AnsweredAssumed Answered

SOQL query with Lead Owner

Question asked by rsanford780 on Dec 5, 2017
Latest reply on Dec 19, 2017 by rsanford780

I am building a SOQL query that pulls Lead information from many records, to populate a Word document template. I am trying to filter the data by Owner. I can't seem to figure out how to name the owner field so that it is recognized both by DocGen and by SalesForce. I've tried Owner.Name and many other things, and they either aren't recognized by DocGen, cause a metadata error, or simply don't return any results when I run the report. 


Any ideas? Thanks in advance. 


Here's the specific query: 


SELECT Owner.Name, Company, RecordTypeId, Name, Project_Request_Description__c, NYBC_Contact_Name__c, Clinical_Trial__c, Geographic_Site__c, Operational_area__c, R_D_Area__c, Business_Model__c, On_hold__c, Lead_Stage__c, Status, (SELECT ActivityDate, Subject, Description FROM Events ORDER BY ActivityDate DESC LIMIT 1) FROM Lead WHERE (Status!=(’Sent to Operations’ OR ‘Qualified’ OR ‘Unqualified’) AND  RecordType.Name=’Research_Services_Lead' AND Internal_Contact__c!='Person1' AND LastName!=’no name’ AND Owner.Name!=(‘Person2’ OR ‘Person3’) ORDER BY On_hold__c