Salesforce错误-“无效的交叉引用ID"; [英] Salesforce error - "invalid cross reference id"

查看:498
本文介绍了Salesforce错误-“无效的交叉引用ID";的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用OmniAuth,OmniAuth-salesforce和以下gem开发Rails应用程序: https://github.com/heroku/databasedotcom

I am developing a Rails app using OmniAuth, OmniAuth-salesforce and this gem: https://github.com/heroku/databasedotcom

我正在将"client_id"和"client_secret"硬编码到我的应用中.然后,对于每个通过Saleforce进行身份验证的用户,我将捕获其oauth令牌,用户ID和实例URL.有了这些,我代表他们创造了线索.

I am hardcoding the "client_id" and "client_secret" into my app. Then for each user that authenticates with Saleforce, I am capturing their oauth token, user id, and instance url. With all this, I am creating leads on their behalf.

如果用户来自我获得"client_id"和"client_secret"的同一帐户,则一切正常.但是,如果我通过另一个Salesforce实例的用户进行身份验证,则会收到无效的交叉引用ID"错误.

Everything works if the user is from the same account where I got the "client_id" and "client_secret". However, if I authenticate with a user from another Salesforce instance, I get an "invalid cross reference id" error.

我希望我的应用程序可以为来自许多不同Salesforce实例的用户提交销售线索.这不可能吗?

I want my app to be submitting leads for users from many different Salesforce intances. Is this not possible?

这是我的完整代码:

client = Databasedotcom::Client.new :client_id => SALESFORCE_CLIENT_ID, :client_secret => SALESFORCE_CLIENT_SECRET
client.authenticate :token => user.salesforce_token, :instance_url => user.salesforce_instance_url
client.materialize("Lead")

lead = Lead.new(:FirstName => first_name, :LastName => last_name, :Email => email, 
                :Phone => phone, :OwnerId => user.salesforce_id, :IsConverted => false,
                :IsUnreadByOwner => true, :Company => contact_company)
lead.save

感谢您的任何建议!

推荐答案

错误将来自您为ownerId设置的user.salesforce_id参考,并导致我认为您正在以某种方式混淆数据,即您正在将user1发送给user2的会话.我没有使用您提到的gem,但是从代码中,我看不到线索实例如何与特定的客户端实例相关联. lead.save如何知道使用您刚创建的客户端实例?

The error will be coming from the user.salesforce_id reference you're setting for ownerId, and leads me to think that you are somehow mixing the data up, i.e. you're sending user1 but to the user2's session. I haven't used the gem you mention, but from the code, i can't see how the lead instance is associated with the particular client instance. How does lead.save know to use the client instance you just created ?

更多地查看materialize("Lead")的工作方式,似乎Lead.new总是要创建与您创建的第一个客户端实例相关联的潜在客户,因此您将尝试发送所有潜在客户您认证的第一个用户.

Looking more at how materialize("Lead") works, it seems like the Lead.new is always going to create a lead that associated with the first client instance you created, so you'd be trying to send all the leads the first user that you authenticate.

这篇关于Salesforce错误-“无效的交叉引用ID";的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆