使用 SOQL 查询 Salesforce 对象列名称

编程入门 行业动态 更新时间:2024-10-27 05:36:33
本文介绍了使用 SOQL 查询 Salesforce 对象列名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我在 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 对象列名称

本文发布于:2023-10-26 08:04:31,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1529576.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:对象   名称   SOQL   Salesforce

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!