Sha256: eade5b0976c9f4cf71b4dfa4d7b46f245d881432c5b9666780c6201b21a55b5b

Contents?: true

Size: 1.02 KB

Versions: 10

Compression:

Stored size: 1.02 KB

Contents

module SugarCRM; class Connection
  # Retrieves a collection of beans that are related 
  # to the specified bean and, optionally, returns 
  # relationship data
  def get_relationships(module_name, id, related_to, opts={})
    login! unless logged_in?
    options = { 
      :query => '',
      :fields => [], 
      :link_fields => [], 
      :deleted => 0
    }.merge! opts  

    json = <<-EOF
      {
        "session": "#{@sugar_session_id}",
        "module_name": "#{module_name}",
        "module_id": "#{id}",
        "link_field_name": "#{related_to.downcase}",
        "related_module_query": "#{options[:query]}",
        "related_fields": #{resolve_related_fields(module_name, related_to)},
        "related_module_link_name_to_fields_array": #{options[:link_fields].to_json},
        "deleted": #{options[:deleted]}
      }
    EOF
    json.gsub!(/^\s{6}/,'')
    SugarCRM::Response.new(send!(:get_relationships, json), @session, {:always_return_array => true}).to_obj
  end
  alias :get_relationship :get_relationships
end; end

Version data entries

10 entries across 10 versions & 2 rubygems

Version Path
sugarcrm_emp-0.10.5 lib/sugarcrm/connection/api/get_relationships.rb
sugarcrm_emp-0.10.1 lib/sugarcrm/connection/api/get_relationships.rb
sugarcrm_emp-0.10.0 lib/sugarcrm/connection/api/get_relationships.rb
sugarcrm-0.9.18 lib/sugarcrm/connection/api/get_relationships.rb
sugarcrm-0.9.17 ./lib/sugarcrm/connection/api/get_relationships.rb
sugarcrm-0.9.16 ./lib/sugarcrm/connection/api/get_relationships.rb
sugarcrm-0.9.15 ./lib/sugarcrm/connection/api/get_relationships.rb
sugarcrm-0.9.14 ./lib/sugarcrm/connection/api/get_relationships.rb
sugarcrm-0.9.13 ./lib/sugarcrm/connection/api/get_relationships.rb
sugarcrm-0.9.12 ./lib/sugarcrm/connection/api/get_relationships.rb