Closed alexdesi closed 13 years ago
This is a bug in the SugarCRM API introduced sometime after 5.5: it works correctly in SugarCRM 5.5.1RC2 (Build 1175) and appears in SugarCRM 6.1.1. The newer version of the SugarCRM API don't seem to return custom fields with the get_relationships call.
It's been documented as bug 43342 with SugarCRM, and is documented here as issue 45 (https://github.com/chicks/sugarcrm/issues/45). See issue 45 for more info. It also seems @openhealth submitted the case as a gold partner, so it may be fixed in the newest (possibly not yet released) versions.
I'm going to close this is a duplicate. If I misunderstood the issue, let me know.
Yes, you're right ! The issue 45 is the same (I am using Sugar 6.1.5) so, I think that I have to use some workaround at the moment.
thank you
Yes, you'll probably need to load the account in an extra step:
account = SugarCRM::Account.find(c.accounts.first.id)
puts account.expiration_date_c
Unfortunately, until this API bug is fixed, accessing custom fields through a relationship isn't going to work properly in recent SugarCRM versions.
Chicks, I also tried to address this issue with
def load_associated_records
array = @owner.class.session.connection.get_relationships(@owner.class._module.name, @owner.id, @association.to_s)
if @owner.class.session.sugar_version =~ /^([\d\.]+)/ && $1 > '5.5.1'
array = @owner.class.session.connection.get_entries(@owner.class._module.name, array.map(&:id))
end
But no cigar: "Access to this object is denied since it has been deleted or does not exist"
It's easier to explain this issue with an example:
expiration_date_c is a field I added in Account Module (in Sugar web interface) In the console:
acc = SugarCRM::Account.find_by_name 'My Account' put acc.expiration_date_c => '03/06/2011"
c = SugarCRM::Contact.find_by_last_name 'User_in_My_Account' puts c.accounts.first.exiration_date_c (note: the only account is My Account) => nil (should be '03/06/2011")
Note: the accounts ID are the same, the object should be the same: (acc.id == c.accounts.first.id) => true
Is this a bug ? or I am overlooking something ?
Alexdesi