简体   繁体   English

无法通过SalesForce REST API访问查找/ ID字段

[英]Unable to access lookup/Id fields via SalesForce REST API

I have an application that accesses a few SalesForce objects via the REST API, however, I don't seem to be able to retrieve or set any fields that are lookup fields. 我有一个通过REST API访问一些SalesForce对象的应用程序,但是,我似乎无法检索或设置任何作为查找字段的字段。 For example, I have a Form__c object that has a Campaign lookup field as well as the standard RecordType field. 例如,我有一个Form__c对象,该对象具有Campaign查找字段以及标准RecordType字段。 If I run the following query via REST: 如果我通过REST运行以下查询:

SELECT Id, Campaign_ c FROM Form _c SELECT ID,Campaign_ c从表格 _c

I receive an error stating that there is no column called Campaign__c. 我收到一条错误消息,指出没有名为Campaign__c的列。

Likewise if I try creating a new Form__c object and I set the RecordTypeId field to a specific record type ID, that value is never actually saved in SalesForce. 同样,如果我尝试创建一个新的Form__c对象,并将RecordTypeId字段设置为特定的记录类型ID,则该值实际上不会保存在SalesForce中。

Is this a limitation of the REST API? 这是REST API的限制吗? Is it unable to work with lookup fields? 它无法使用查找字段吗? Or am I doing something wrong? 还是我做错了什么?

Any help is highly appreciated. 非常感谢您的帮助。

In this query: 在此查询中:

SELECT Id, Campaign_c FROM Form_c

It looks like Campaign_c (and Form_c) are missing an underscore. 看起来Campaign_c(和Form_c)缺少下划线。 Both should end with __c (two underscores and a 'c'). 两者都应以__c (两个下划线和一个'c')。

Check Profile of user that's integrating via REST? 检查通过REST集成的用户的个人资料?

  1. I suspect "field level security" is preventing you from seeing these fields. 我怀疑“字段级安全性”阻止您看到这些字段。
  2. Plus - in order to use lookups to Campaigns your user must have at least Read access to them (check Campaign object for "Read" not checked or Tab visibility set to "hidden"). 加号-为了对Campaigns使用查找,您的用户必须至少具有对它们的读取访问权限(检查Campaign对象是否选中“ Read”或“ Tab可见性”设置为“ hidden”)。
  3. Campaigns are special, I'm not sure if you don't need the "Marketing User" checked as well on your user record. 广告系列非常特殊,我不确定您是否也不需要在用户记录中选中“营销用户”。

As for RecordType - weird. 至于RecordType-很奇怪。 If anything I'd expect it to throw an error if your Profile is not set to be able to use given rec. 如果您的个人资料未设置为能够使用给定的记录,那么我希望它会引发错误。 type (even if you're SysAdmin). 类型(即使您是SysAdmin)。 Are you using any library that might be swallowing errors? 您是否正在使用任何可能吞下错误的库?

Last but not least - fire a REST describe call (from your application or from Workbench ) to /services/data/v26.0/sobjects/Form__c/describe ? 最后但并非最不重要的一点-触发REST描述调用(从您的应用程序或从Workbench )到/services/data/v26.0/sobjects/Form__c/describe

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM