Salesforce 从两个不同的对象中检索字段 - (SOQL) Simple Salesforce Python
Saleforce retrieving fields from two different objects - (SOQL) Simple Salesforce Python
我正在使用 python 的 simpleSalesforce 库来查询 SalesForce。
我正在查看 SalesForce 中的两个不同对象:帐户和后端(父子)。 account中的Id通过acc_id
匹配到Backend的记录
我正在尝试这样做:
sf.query_all("SELECT AccEmail__c, (select custid from Backend__c) from Account where Id in (select acc_id from Backend__c where custid LIKE '%CUST%')")
但我收到的回复显示:
格式错误的请求 - 不理解关系 - 在查询调用的 FROM 部分。如果您尝试使用自定义关系,请务必在自定义关系名称后附加“__r”。请参考您的 WSDL 或描述调用以获取适当的名称。", 'errorCode': 'INVALID_TYPE'}]
我做错了什么我该如何解决?
了解关系
- https://developer.salesforce.com/docs/atlas.en-us.soql_sosl.meta/soql_sosl/sforce_api_calls_soql_relationships_understanding.htm
- https://developer.salesforce.com/docs/atlas.en-us.soql_sosl.meta/soql_sosl/sforce_api_calls_soql_relationships_and_custom_objects.htm
很可能您的查询必须类似于
SELECT AccEmail__c,
(select custid__c from Backends__r)
from Account
where Id in (select account__c from Backend__c where custid__c LIKE '%CUST%')
甚至
SELECT AccEmail__c,
(select custid__c from Backends__r where custid__c LIKE '%CUST%')
from Account
where Id in (select account__c from Backend__c where custid__c LIKE '%CUST%')
或者如果你想要它平坦
SELECT CustId__c, Account__r.AccEmail__c
FROM Backend__c
WHERE CustId__c LIKE '%CUST%'
我正在使用 python 的 simpleSalesforce 库来查询 SalesForce。
我正在查看 SalesForce 中的两个不同对象:帐户和后端(父子)。 account中的Id通过acc_id
匹配到Backend的记录我正在尝试这样做:
sf.query_all("SELECT AccEmail__c, (select custid from Backend__c) from Account where Id in (select acc_id from Backend__c where custid LIKE '%CUST%')")
但我收到的回复显示:
格式错误的请求 - 不理解关系 - 在查询调用的 FROM 部分。如果您尝试使用自定义关系,请务必在自定义关系名称后附加“__r”。请参考您的 WSDL 或描述调用以获取适当的名称。", 'errorCode': 'INVALID_TYPE'}]
我做错了什么我该如何解决?
了解关系
- https://developer.salesforce.com/docs/atlas.en-us.soql_sosl.meta/soql_sosl/sforce_api_calls_soql_relationships_understanding.htm
- https://developer.salesforce.com/docs/atlas.en-us.soql_sosl.meta/soql_sosl/sforce_api_calls_soql_relationships_and_custom_objects.htm
很可能您的查询必须类似于
SELECT AccEmail__c,
(select custid__c from Backends__r)
from Account
where Id in (select account__c from Backend__c where custid__c LIKE '%CUST%')
甚至
SELECT AccEmail__c,
(select custid__c from Backends__r where custid__c LIKE '%CUST%')
from Account
where Id in (select account__c from Backend__c where custid__c LIKE '%CUST%')
或者如果你想要它平坦
SELECT CustId__c, Account__r.AccEmail__c
FROM Backend__c
WHERE CustId__c LIKE '%CUST%'