Programatically change user field (entity reference) in drupalgap with user_save()? We are using DrupalGap to make an app. We have nodes (content type chargingstations) which we want our users to be able to "check" into by pressing a button. Until now I have created a button on the nodes page in DrupalGap which executes a function on an onClick event. 

This function takes in a NID which is the node I want the user to check into. I then have a field on the user called "checked_in_chargingstation" which is an entity reference field. 

In the DrupalGap documentation there is not much information on user_update. It just says "...". But it seems like you can update a node by passing the NID. So I figured I could do the same for user? But it doesen't seem to work. I get a success alert, but I can't see any changes to the users. 

My check in code. Drupal.user.uid gets the current users uid. 

function check_in($nid){
  var $field_checked_in_chargingstation = {};
  $field_checked_in_chargingstation["und"] = {
    target_id: $nid,
  };

  var user = {
    uid: Drupal.user.uid,
    field_checked_in_chargingstation: $field_checked_in_chargingstation,
  }

  user_save(user, {
    success:function(result){
      console.log(result);
    }
  });
}


In the console I get: 



Looking at the json I can see:

"field_checked_in_chargingstation": {
 "und": [
  {
   "target_id": "29088"
  }
 ]
},


But this is the wrong id. This is an old node which I have assigned before from Drupal and "edit" user. So it doesen't seem updated. Trying to drush cc all doesen't seem to work either. 

If I try to edit the user from the app I only see null values for the entity reference field. One suggestion in the Drupalgap documentation is to make an entity reference view http://docs.drupalgap.org/7/Entities/Entity_Reference which I also did. 

Sorry if this is a bit long. And I'm not sure if I should post it here on Stack Exchange or as an issue on DrupalGap.
It depends largely on what Widget you have selected for your entity reference field on your Manage Display page. The easiest widget to work with is the Autocomplete widget, at which point you'd send up this JSON:

"field_checked_in_chargingstation": {
 "und": [
  {
   "target_id": "... (29088)"
  }
 ]
},


The Services module is coupled with the forms system in Drupal, so as you change the widget on a field, the JSON data you need to send to Drupal may change.