chicks / sugarcrm

A ruby based REST Client for SugarCRM
MIT License
90 stars 64 forks source link

change of email from invalid to valid #62

Open ziaulhuda opened 13 years ago

ziaulhuda commented 13 years ago

Hi,

I have a contact which have an invalid and a valid email address. When I change a value of an attribute of that contact and call save function, the new value of changed attribute is stored which is good but the problem is the invalid email address is changed automatically to valid email.

Is this a problem of gem or api?

Waiting for response

chicks commented 13 years ago

Can you give me some code to reproduce this issue?

ziaulhuda commented 13 years ago

Here is the code. just change the conditions to get some contact who have a invalid email address attached to it

sc_contacts = @sugarcrm::Contact.find(:all, :conditions=>{:date_modified=>">= '#{last_r.gmtime.strftime("%Y-%m-%d %H:%M:%S")}'"})

sc_contacts.each do|contact| contact.contacts_sys_cleverreachid_c = new_id contact.save end

It will change the invalid email to valid email. contacts_sys_cleverreachid_c is a user defined field. You may use any other field for updating

chicks commented 13 years ago

Whoa... This is a SugarCRM bug. I can confirm this because if you enable debugging on the connection and call save! on the record, you don't see any values passed for the email address.

To reproduce:

  1. Locate a contact record with an invalid or opt-out email address
  2. Load the record a = SugarCRM::User.find(id)
  3. Save the record

    a.save!

    1. Opt-out and invalid email will no longer be set.

    set_entry request does not pass any parameters except id:

    set_entry: Request: { "session": "be3da93ff2c9ecef99fb5123cb47a0e3", "module_name": "Contacts", "name_value_list": {"id":{"name":"id","value":"a3d2b5ca-5126-5953-8422-4dc0d2392dcf"}} }

    set_entry: JSON Response: {"id"=>"a3d2b5ca-5126-5953-8422-4dc0d2392dcf"}