微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

在RubyZoho中,如何设置Task.related_to Lead.id?

我在 RubyZoho的论坛上写了这个问题,但它在那里萎靡不振,这是一个非常简单的问题,值得更多的观众.

我已经使用RubyZoho将新的Lead记录上传到Zoho CRM API,现在我想上传一个任务,其中“相关”字段设置为该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网站上获得了一个空白的“相关内容”的任务记录.当我尝试task.related_to =’Lead’; task.relatedtoid = lead.leadid,我得到一个未定义的方法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 is the ID of the Owner

SEMODULE can be Accounts or Leads or Cases

SEID is the ID of the Record given in the SEMODULE

CONTACTID is the ID of the contact record

另外,如果你看一下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帮助您链接

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐