Answers.Body: <p>EDIT: I figured out what went wrong. The gender_id change must be specified as a parameter in the .create() function. It shouldn't be changed in the callback. </p>
  
  <p>The correct code is: </p>
  
  <pre><code>crmAPI.create('contact', {id:'12966', gender_id:'2'},
     function (result) {
         console.log(result); 
         val=result.values[0]; 
         console.log('UPDATED CONTACT: '+ val.display_name + " " + val.gender_id + " " + val.country_id);
  }); 
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-01-25T02:13:49.353Z
Answers.LastActivityDate: 2017-01-25T02:13:49.353Z
Answers.UserDisplayName: Stuti Vishwabhan
Body: <p>According to CiviCRM API documentation, the .create() function with a specified contact ID should modify the records within CiviCRM; however, even after trying that, I still can't seem to properly push changes to CiviCRM. </p>
  
  <p>In the code below, I'm trying to change Jane Doe's gender from "1" to "2", and when I change that by setting val.gender_id="2", it prints out the right result. However, when I try to "get" Jane Doe's information afterwards, it prints her gender_id as "1". So, it doesn't actually update the CiviCRM database. </p>
  
  <p>Is there a way to fix this? </p>
  
  <p>//TESTING FOR UPDATING CONTACT INFORMATION OF 'JANE DOE' in CIVICRM DATABASE</p>
  
  <pre><code>crmAPI.create('contact', {id:'12966'},
    function (result) {
        console.log(result); 
        val=result.values[0]; 
        val.gender_id='2'; 
        console.log('UPDATED CONTACT: '+ val.display_name + " " + val.gender_id + " " + val.country_id);
  
  crmAPI.get('contact', {id:'12966'}, 
    function(result) {
      console.log(result); 
      for (var i in result.values) {
        val=result.values[i]; 
        console.log(val.display_name + " " + val.gender_id + " " + val.country_id); 
      }
    }
  ); 
  </code></pre>
  
  <p>});</p>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-01-26T12:17:25.403Z
Comments.Text: try crmAPI.create('contact', {id:'12966', gender_id:2}?
Comments.UserDisplayName: ErikH - CiviCooP
Tags: <contacts>
Title: How do you update the contact information of someone in CiviCRM?
ThreadText: # How do you update the contact information of someone in CiviCRM?
  
  (Asked by: username_0 on 2017-01-25)
  
  According to CiviCRM API documentation, the .create() function with a specified contact ID should modify the records within CiviCRM; however, even after trying that, I still can't seem to properly push changes to CiviCRM.
  
  In the code below, I'm trying to change Jane Doe's gender from "1" to "2", and when I change that by setting val.gender\_id="2", it prints out the right result. However, when I try to "get" Jane Doe's information afterwards, it prints her gender\_id as "1". So, it doesn't actually update the CiviCRM database.
  
  Is there a way to fix this?
  
  //TESTING FOR UPDATING CONTACT INFORMATION OF 'JANE DOE' in CIVICRM DATABASE
  
  ```
  crmAPI.create('contact', {id:'12966'},
    function (result) {
        console.log(result); 
        val=result.values[0]; 
        val.gender_id='2'; 
        console.log('UPDATED CONTACT: '+ val.display_name + " " + val.gender_id + " " + val.country_id);
  
  crmAPI.get('contact', {id:'12966'}, 
    function(result) {
      console.log(result); 
      for (var i in result.values) {
        val=result.values[i]; 
        console.log(val.display_name + " " + val.gender_id + " " + val.country_id); 
      }
    }
  ); 
  
  ```
  
  });
  
  **Tags:** contacts
  
  > **Comments:**
  > **username_1**: try crmAPI.create('contact', {id:'12966', gender_id:2}?  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_0 on 2017-01-25. Score: 2
  
  EDIT: I figured out what went wrong. The gender\_id change must be specified as a parameter in the .create() function. It shouldn't be changed in the callback.
  
  The correct code is:
  
  ```
  crmAPI.create('contact', {id:'12966', gender_id:'2'},
     function (result) {
         console.log(result); 
         val=result.values[0]; 
         console.log('UPDATED CONTACT: '+ val.display_name + " " + val.gender_id + " " + val.country_id);
  }); 
  
  ```
  
  
  ---
  
  