我在使用SOAP API查询模式中的关系时遇到了一些问题?

时间:2011-11-11 02:52:59

标签: soql

    I am trying to query the relationship "Assigned_To__r" within the "Case" object, so I can return the Name of the User that is currently assigned to the case.I have tried many different syntaxes, and read many different web pages on this, but can't seem to figure it out. Here is my current syntax that isn't working, but as I said, I've tried many different combinations 
Please help.


`select Id,CaseNumber,Subject,(select Name from Assigned_To__r) 
from Case 
where Closure_Code__c <> 'Invalid Support Case' 
and Closure_Code__c <> 'Duplicate Case' 
and Closure_Code__c <> 'Spam''

这是我得到的错误:

  

INVALID_TYPE:   CaseNumber,Subject,(从Assigned_To__r中选择Name)来自Case where   ^

     

行的错误:1:列:48不理解关系   在FROM查询调用的一部分'Assigned_To_ r'。如果你正在尝试   使用自定义关系,请确保在后面附加' _r'   自定义关系名称。请参考您的WSDL或描述   要求适当的名字。

1 个答案:

答案 0 :(得分:0)

您的SOQL存在一些格式问题。

如果您可以澄清Assigned_To__c自定义字段与Case的关系,我可以更清楚地了解如何帮助您解决问题。但是,根据我对您的情况的最佳猜测(具体而言,Closure_Code__c是标准选项列表,而Assigned_To__rCase上的自定义子级到父级关系字段,我会下注你想要的SOQL看起来像这样:

SELECT Id, CaseNumber, Subject, Assigned_To__r.Name
  FROM Case
 WHERE Closure_Code__c NOT IN ('Invalid Support Case', 'Duplicate Case', 'Spam')