+ Start a Discussion
debradebra 

SOQL Query to connect data from emailServicesFunction and ApexClass objects

I have a simple requirement to retrieve the error routing email address for a specific email service.  I have not found a single SOQL statement to retrieve the value based on the Apex class assigned to the email service.  Normal relationship field query methods do not seem to work with the ApexClassId field on the emailServicesFunction object.
Here are the two queries that will get the value I need but would like to understand why a specific relationship field does not query as expected so that this could be done with one statement!

1st SOQL: select Id from Apexclass where name = 'MyInboundEmailHandlerClass';
2nd SOQL taking the result from the 1st:  select errorRoutingAddress from emailServicesFunction  where ApexClassid = '01p6C000000LicNQAS'

Thanks!
Best Answer chosen by debra
Raj VakatiRaj Vakati
Try this 
 
Select Id,ApexClassId from EmailServicesFunction where ApexClassId IN (select Id from Apexclass where name = 'MyInboundEmailHandlerClass')

 

All Answers

Raj VakatiRaj Vakati
Try this 
 
Select Id,ApexClassId from EmailServicesFunction where ApexClassId IN (select Id from Apexclass where name = 'MyInboundEmailHandlerClass')

 
This was selected as the best answer
debradebra
Thanks thought I had tried this but must have had error in my original syntax!