问题描述
我在 Salesforce 实例和 S3 存储桶之间的 SnapLogic 集成中使用 Salesforce SOQL snap.
我正在尝试在 Salesforce SOQL 快照字段SOQL 查询*"中使用 SOQL 查询来返回对象的列名称.例如,我想运行 SOQL 查询以返回帐户"对象的列名.
我这样做是因为 SOQL 不允许选择 *".我已经在 Apex 中看到了这方面的代码解决方案,但我正在寻找一种仅使用 SOQL 查询的方法.
您想查询元数据?可用表的名称,您可以在每个表中看到的列的名称,可能是类型而不是真实的帐户/联系人/...数据,对吗?
您可能需要稍微提高 API 的版本,当前是 47/48,因此某些对象在您当前的版本中可能不可见.另外 - 你有哪些 API 选项?肥皂,休息?工具 API"是一种选择吗?因为它有非常好的官方
我在 REST API 参考中没有看到该表,但它似乎在 Workbench 中查询 OK,所以有希望.
通常尝试在 Google 上搜索有关 EntityDefinition、FieldDefinition、EntityParticle 的信息……例如,这是了解哪些表对您可见的不错方法:
SELECT KeyPrefix、QualifiedApiName、Label、IsQueryable、IsDeprecatedAndHidden、IsCustomSetting从实体定义WHERE IsCustomizable = true AND IsCustomSetting = false
或者在紧要关头,您可以尝试查看您的用户有权查询哪些字段.这样做有点迂回,但我不知道您的连接器可以看到"哪些表.
I am using the Salesforce SOQL snap in a SnapLogic integration between our Salesforce instance and an S3 bucket.
I am trying to use a SOQL query in the Salesforce SOQL snap field "SOQL query*" to return the column names of an object. For example, I want to run a SOQL query to return the column names of the "Account" object.
I am doing this because SOQL does not allow "Select *". I have seen code solutions in Apex for this, but I am looking for a way to do it using only a SOQL query.
You want to query metadata? Names of available tables, names of columns you can see in each table, maybe types instead of real Account/Contact/... data, correct?
You might have to bump the version of the API up a bit, current is 47 / 48 so some objects might not be visible in your current one. Also - what API options you have? SOAP, REST? Is "Tooling API" an option? Because it has very nice official FieldDefinition
table to pull this.
It's not perfect but this could get you started:
SELECT EntityDefinition.QualifiedApiName, QualifiedApiName, DataType
FROM FieldDefinition
WHERE EntityDefinition.QualifiedApiName IN ('Account', 'Contact', 'myNamespace__myCustomObject__c')
I don't see the table in the REST API reference but it seems to query OK in Workbench so there's hope.
Generally try to Google around about EntityDefinition, FieldDefinition, EntityParticle... For example this is a decent shot at learning which tables are visible to you:
SELECT KeyPrefix, QualifiedApiName, Label, IsQueryable, IsDeprecatedAndHidden, IsCustomSetting
FROM EntityDefinition
WHERE IsCustomizable = true AND IsCustomSetting = false
Or in a pinch you could try to see which fields your user has permission to query. It's bit roundabout way to do it but I have no idea which tables your connector can "see".
这篇关于使用 SOQL 查询 Salesforce 对象列名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!