Saleforce 从两个不同的对象中检索字段 - (SOQL) 简单的 Salesforce Python [英] Saleforce retrieving fields from two different objects - (SOQL) Simple Salesforce Python

查看:90
本文介绍了Saleforce 从两个不同的对象中检索字段 - (SOQL) 简单的 Salesforce Python的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用 Python 的 simpleSalesforce 库来查询 SalesForce.

I am using simpleSalesforce library for python to query SalesForce.

我在 SalesForce 中查看两个不同的对象:帐户和后端(父子).account中的Id通过acc_id匹配Backend的记录

I am looking at two different object in SalesForce: Account and Backend (parent-child). The Id in account matches the records of Backend through acc_id

我正在尝试这样做:

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'}]

Malformed request - didn't understand the relationship - in FROM part of query call. If you are attempting to use a custom relationship, be sure to append the '__r' after the custom relationship name. Please reference your WSDL or the describe call for the appropriate names.", 'errorCode': 'INVALID_TYPE'}]

我做错了什么,我该如何解决?

What am I doing wrong how can I fix this?

推荐答案

了解关系

很可能您的查询必须类似于

Most likely your query has to be something like

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%'

这篇关于Saleforce 从两个不同的对象中检索字段 - (SOQL) 简单的 Salesforce Python的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆