简体   繁体   English

databasedotcom gem sobject问题

[英]databasedotcom gem sobject issue

I am using the databasedotcom gem in a Ruby on rails app to access my Salesforce instance but I am having some trouble getting an sObject to be created under the correct namespace. 我在Ruby on rails应用程序中使用databasedotcom gem来访问我的Salesforce实例,但是在以正确的名称空间创建sObject时遇到了一些麻烦。 I already have a model called User in my database, so when I first tried to get a list of User objects from Salesforce I was getting my locally defined model. 我的数据库中已经有一个名为User的模型,因此当我第一次尝试从Salesforce获取User对象的列表时,我正在获取本地定义的模型。

After reading around I found that I can specify a namespace for the client which I use to connect to my Salesforce instance, using sobject_module . 阅读后,我发现可以使用sobject_module为客户端指定名称空间,该名称空间用于连接到我的Salesforce实例。 I did that and I also defined a module in my project for the Salesforce models. 我做到了,并且在我的项目中为Salesforce模型定义了一个模块。 However I still get back the locally defined User model rather than the Salesforce defined User model. 但是,我仍然返回本地定义的User模型,而不是Salesforce定义的User模型。 If I try to access a model that is present in Salesforce but not locally then the object is returned under the correct namespace. 如果我尝试访问Salesforce中存在但本地没有的模型,则该对象将在正确的名称空间下返回。

Why does this happen? 为什么会这样? I thought once I set the sobject_module for the client it should return the model under the correct namespace. 我认为,一旦为客户端设置了sobject_module ,它应该在正确的命名空间下返回模型。 Here is my client connection: 这是我的客户端连接:

client = Databasedotcom::Client.new(
                client_id: "my_client_id",
                client_secret: "my_client_secret",
                sobject_module: "Sale"
            )

client.oauth_token = client.authenticate( username: "my_username", password: "my_password")

Here is the module i defined for the Salesforce objects: 这是我为Salesforce对象定义的模块:

module Sale

end

This works, it returns <Sale::Organization:0x007f90ef8ad590> 这有效,它返回<Sale::Organization:0x007f90ef8ad590>

client.materialize("Organization")

However this does not, it returns <User:0x007f8f7e5a06d0> 但这不是,它返回<User:0x007f8f7e5a06d0>

client.materialize("User")

Thanks in advance 提前致谢

Update 更新资料

I was not able to get this to work for me, but I found another gem and it worked perfectly with it. 我无法使它适合我,但我找到了另一个宝石,它非常适合它。 I used the restforce gem 我使用了restforce宝石

我认为您已经得出了这个结论,但是Heroku不再维护databasedotcom gem。

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

相关问题 Ruby Gem“Databasedotcom”同样的对象问题 - Ruby Gem “Databasedotcom” same object issue databasedotcom gem AssignmentRules - databasedotcom gem AssignmentRules Rails中的显示方法不适用于Databasedotcom gem - Show method in Rails not working with databasedotcom gem 在没有模型的情况下验证电子邮件格式-Databasedotcom gem - Validate email format without model - databasedotcom gem Salesforce REST API:Databasedotcom gem可上传附件 - Salesforce REST API: Databasedotcom gem to upload attachments Databasedotcom gem:根据会话ID检索用户信息 - Databasedotcom gem : Retrieve user info based on session id Salesforce Databasedotcom gem:查询不会返回正确的结果 - Salesforce databasedotcom gem: Query doesn't return right results 在Rails中未为此组织启用REST API(使用databasedotcom gem的Salesforce API) - The REST API is not enabled for this Organization (Salesforce API using databasedotcom gem) in Rails 使用databasedotcom ruby​​ gem访问Salesforce时,如何获取特定用户(或帐户)的ActivityHistory - When using databasedotcom ruby gem to access salesforce, how do I get the ActivityHistory for a particular User (or Account) 使用Databasedotcom-rails gem从RoR应用程序创建Salesforce自定义对象记录时出现NoMethodError - NoMethodError when creating a Salesforce custom object record from a RoR app with databasedotcom-rails gem
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM