我在鲁比佐霍的论坛上写下了这个问题,但它在那里很受煎熬,这是一个如此简单的问题,值得更多的读者去关注。
我使用rubyzoho向zoho crm api上传了一个新的lead记录,现在我想上传一个任务,并将其“related to”字段设置为该lead。
配置rubyzoho:
RubyZoho.configure do |config|
config.api_key = Setting.plugin_redmine_tigase['zoho_authorization_token']
config.crm_modules = [
'Leads',
'Tasks'
]
config.ignore_fields_with_bad_names = true
config.cache_fields = true
end
创建潜在客户:
lead = RubyZoho::Crm::Lead.new
lead.first_name = splut.first
lead.last_name = splut.last
lead.full_name = params[:name]
lead.company = params[:company]
lead.email = params[:mail]
lead.description = description
lead.save
创建任务:
found = RubyZoho::Crm::Lead.find_by_email(params[:mail])
lead = found.first
task = RubyZoho::Crm::Task.new
task.related_to = lead.id
task.subject = params[:subject]
task.description = description
task.save
我尝试了
task.related_to = lead.leadid
,并在zoho网站上获得了一个带有空白“related to”的任务记录。当我尝试task.related_to = 'Lead'; task.relatedtoid = lead.leadid
时,自然会得到一个undefined method relatedtoid=
,因为变量没有setter。那我错过了什么?我怎么做这个简单的事情?
最佳答案
如果你看一下文档,它有一个关于
https://www.zoho.com/creator/help/script/creating-a-record-in-zoho-crm.html#create-lead
taskInfo = {
"Task Owner" : input.Owner_Name,
"SMOWNERID" : input.Owner_ID,
"Subject" : input.Subject,
"Description" : input.Description,
"SEMODULE" : "Accounts",
"SEID" : input.Account_ID,
"CONTACTID" : input.Contact_ID};
crmResp = zoho.crm.create("Tasks", taskInfo);
smownerid是所有者的ID
semodule可以是accounts、lead或cases
seid是semodule中给定的记录的id
contactID是联系人记录的ID
如果您查看
ruby_zoho_rspec
来创建新任务https://github.com/amalc/rubyzoho/blob/950ffe369252f8fad3e7ae67ebddec859c84e19b/spec/ruby_zoho_spec.rb
it 'should save an task record related to an account' do
VCR.use_cassette 'zoho/task_related_to_account' do
a = RubyZoho::Crm::Account.all.first
e = RubyZoho::Crm::Task.new(
:task_owner => a.account_owner,
:subject => "Task should be related to #{a.account_name} #{Time.now}",
:description => 'Nothing',
:smownerid => "#{a.smownerid}",
:status => 'Not Started',
:priority => 'High',
:send_notification_email => 'False',
:due_date => '2014-02-16 16:00:00',
:start_datetime => Time.now.to_s[1, 19],
:end_datetime => '2014-02-16 16:00:00',
:related_to => "#{a.account_name}",
:seid => "#{a.accountid}",
:semodule => 'Accounts'
)
r_expected = e.save
r = RubyZoho::Crm::Task.find_by_activityid(r_expected.id)
r.first.subject[0..20].should eq(r_expected.subject[0..20])
end
因此,通过指定
SEMODULE
和SEID
关于ruby - 在RubyZoho中,如何将Task.related_to设置为Lead.id?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/50028775/