sugarcrm
sugarcrm copied to clipboard
Having problems associating custom objects
Hi again, i hope you will be able to help me out :) I have 2 custom objects in SugarCRM - Merchant and Bank and i need an one-to-many relationship between them(one Merchant has many Banks). The gem provides pretty good relationship builder and it has been working ok for standart objects, but i just can`t get it to work on the custom ones.
- I have created the relationship in Studio.
- A new table in the database has been created(i suppose that is standard SugarCRM stuff). And than i`m just wondering how to connect the two objects? Here is a bit of code:
merchant = find_sugarcrm_object('merchant', 'sf_id', obj.sf_merchant) obj.emp_merchant << merchant if merchant
obj == SugarCRM::BankAccount The find_sugarcrm_object method returns a merchant object(it`s working ok)
What i get is an "undefined method emp_merchant" for the Bank object. Its obvious that there is a problem there, but i can
t figure out what field to use for the relation.
1.9.2-p320 :016 > bank.new #<SugarCRM::Namespace0::EmpSettlementBankAccount account_number: nil, assigned_user_id: nil, assigned_user_name: nil, bank_address: nil, bank_name: nil, bic_code: nil, created_by: nil, created_by_name: nil, currencyisocode: nil, date_entered: nil, date_modified: nil, deleted: false, description: nil, emp_merchant_emp_settlement_bank_account_1_name: nil, holder_address: nil, iban: nil, id: nil, modified_by_name: nil, modified_user_id: nil, name: nil, processing_currency: nil, routing_number: nil, settlement_currency: nil, sf_contract: nil, sf_createdby: nil, sf_createdbyid: nil, sf_createddate: nil, sf_id: nil, sf_iso: nil, sf_lastactivitydate: nil, sf_lastmodifiedby: nil, sf_lastmodifiedbyid: nil, sf_lastmodifieddate: nil, sf_merchant: nil, sf_merchant_id: nil, sf_owner: nil, sf_ownerid: nil, swift: nil>
P.S. I have also tried to use the associate method, but it was no good. No errors were thrown, but no relationship either