Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to save data to Sugar #104

Open
mattymess opened this issue Apr 22, 2014 · 5 comments
Open

Unable to save data to Sugar #104

mattymess opened this issue Apr 22, 2014 · 5 comments

Comments

@mattymess
Copy link

This only started happening in the past few weeks, so at first I thought it was an issue on the SugarCRM side, but their technical support said it doesn't appear to be a Sugar error.

If I get an object from Sugar and try to save it, the gem responds with false when doing object.save. If I use object.save!, it responds with an InvaidRecord error

[15] pry(main)> account = SessionNamespace::Account.first
=> #<SugarCRM::Namespace1::Account:0x3fd284c25150>
[16] pry(main)> account.save
=> false
[17] pry(main)> account.save!
SugarCRM::InvalidRecord: Team count cannot be blank
from /Users/mattmessinger/.rvm/gems/ruby-2.0.0-p195@viewfinder/gems/sugarcrm-0.9.18/lib/sugarcrm/attributes/attribute_methods.rb:171:in `save_modified_attributes!'
@chicks
Copy link
Owner

chicks commented Apr 22, 2014

Did you upgrade Sugar recently? The gem enforces validations defined by the Sugar metadata on the module. Try setting team count to 1, and save! again.

@mattymess
Copy link
Author

We haven't upgraded Sugar. Maybe they did it without telling us?

I'm honestly not even sure what team count is. I've never seen it before.

@chicks
Copy link
Owner

chicks commented Apr 22, 2014

team_count is the total number of teams associated with a record. It will get calculated automatically on save, but since the module vardefs mark the field as "required", the gem requires you put a value there.

@mattymess
Copy link
Author

If I set account.team_count = 1' and then do asave`, it does work. My question now is, why all of a sudden do we need to set this value?

We've been communicating and updating data in Sugar via the gem for months without needing to do this.

@chicks
Copy link
Owner

chicks commented Apr 22, 2014

So, the field is required because the Sugar Accounts metadata is marking it as required. This could have been changed a number of ways:

  1. Someone could have marked the field as required in Studio
  2. The Sugar instance could have been upgraded, and the upgrade changed the field to be required.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants