views:

77

answers:

1

Here is the documentation for the SugarCRM 5.5 API:

set_relationship

http://developers.sugarcrm.com/docs/PRO/5.5/Developer_Guides/-docs-Developer_Guides-Sugar_Developer_Guide_5.5.1-Chapter%202%20Application%20Framework.html#9000526

This is the gem which is creating methods for me to access it (line 110):

http://github.com/dennijo/Ruby-Sugar/blob/master/lib/ruby_sugar/client.rb

QUESTION: What is the actual format with an example for me to make a relationship between an Account and a Contact? I am confused in terms of what to pass. It looks like the API requires 5 parameters, but the gem only passes two. The documentation for the gem says to pass a hash as follows:

Assumes:
  @client = RubySugar::Client.new(user,pass,url,true)

  def set_relationship(mod,id,related,related_id)
    data = [
      {:module1=>mod,:moudule1_id=>id.to_s,:module2=>related,:module2_id=>related_id.to_s}
    ]
    @client.set_relationship(data)
  end
A: 

I think you're getting confused between the actual sugar-api (which says to use five parameters) and the "api" of the gem (which uses just the hash of values).

Line 110 of the gem (as you described) only uses two parameters - but again, that is a call to a ruby method... which is no doubt defined elsewhere in the code.

No doubt, somewhere inside the sugar gem - it will turn that hash into the real parameters to pass to Sugar... but all you need to worry about is populating the hash correctly, which should be covered in the docs.

Taryn East