简体   繁体   English

simple-salesforce 无法识别自定义对象

[英]simple-salesforce not recognizing custom object

I am using simple_salesforce and get all records of a custom object called "SER__Condition__c".我正在使用 simple_salesforce 并获取名为“SER__Condition__c”的自定义对象的所有记录。 I know for a fact that that is the name because I got a list of table names from our administrator.我知道这个名字是因为我从我们的管理员那里得到了一个表名列表。
"api" is an instance of "simple_salesforce.Salesforce". “api”是“simple_salesforce.Salesforce”的一个实例。
This is the command I'm executing:这是我正在执行的命令:

pprint(api.query('SELECT Id FROM SER__Condition__c'))

Which returns this error:返回此错误:

  File "path\to\lib\simple_salesforce\api.py", line 698, in _exception_handler
    raise exc_cls(result.url, result.status_code, name, response_content)
simple_salesforce.api.SalesforceMalformedRequest: Malformed request https://xxx.salesforce.com/services/data/v29.0/query/?q=SELECT+Id+FROM+SER__Condition__c. Response content: [{'message': "\nSELECT Id FROM SER__Condition__c\n
       ^\nERROR at Row:1:Column:16\nsObject type 'SER__Condition__c' is not supported. If you are attempting to use a custom object, be sure to append the '__c' after the entity name. Please reference your WSDL or the describe call for the appropriate names.", 'errorCode': 'INVALID_TYPE'}]

Using the exact same command for a default object returns all the records as expected:对默认对象使用完全相同的命令会按预期返回所有记录:

pprint(api.query('SELECT Id FROM Account'))

The same also holds true for these two:这两个也同样适用:

api.Account.get('xxxxxxxxxxxxxxxxxx')
api.SER__Condition__c.get('xxxxxxxxxxxxxxxx')

It probably is a permissions issue.应该是权限问题。 Make sure the SER__Condition__c object is visible to the user you are running the query as.确保 SER__Condition__c 对象对您运行查询的用户可见。

I am 90% sure the issue is with the name of the object.我 90% 确定问题出在对象的名称上。 Per Salesforce, the naming convention for a custom object cannot include two consecutive underscores.对于 Salesforce,自定义对象的命名约定不能包含两个连续的下划线。 From the Salesforce error message on object creation: "Error: The Object Name field can only contain underscores and alphanumeric characters. It must be unique, begin with a letter, not include spaces, not end with an underscore, and not contain two consecutive underscores."来自对象创建的 Salesforce 错误消息:“错误:对象名称字段只能包含下划线和字母数字字符。它必须是唯一的,以字母开头,不包含空格,不以下划线结尾,并且不包含两个连续的下划线.”

If you change "SER__Condition__c" to "SER_Condition__c" (a single underscore between "SER" and "Contition") it should fix the issue.如果您将“SER__Condition__c”更改为“SER_Condition__c”(“SER”和“Contition”之间的单个下划线),它应该可以解决问题。

Yes, I resolved this issue by editing the user profile's custom object permissions.是的,我通过编辑用户配置文件的自定义对象权限解决了这个问题。 It looks like it defaults to none.看起来它默认为无。

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

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