SOQL加入salesforce

时间:2013-08-02 09:11:22

标签: soql

我如何从此查询中访问附件ID ..

List<Email__c> e=[SELECT email_body__c,(SELECT Id,Name FROM Attachments) FROM Email__C where id='emailobjectid'];

for(email__c e1:e)
 {
                        System.debug(e1.Attachments.id);
 }

Getting error.. Invalid foreign key relationship Email__c.Attachments

1 个答案:

答案 0 :(得分:1)

拆分查询。

List<Email__c> e=[SELECT id, email_body__c FROM Email__C where id='emailobjectid'];

for(email__c e1:e){
     List<Attachments> attList = [SELECT Id,Name FROM Attachments where parentId=:e1.id];
     for(Attachment att:attList)
          System.debug(att.id+'   '+att.name);
 }