Why would custom fields not update? I am having trouble updating custom fields programmatically. The code appears below and is in the body of my custom module. When I run this changing the title, it changes OK. But, when I try to do this with the custom field, the field doesn't get updated and I don't understand why. Should I be wrapping this into some hook? Is there a cache not being cleared somewhere? Basically, what am I missing when it comes to programmatically updating fields.

$nodes_to_load = $query-&gt;execute();
if (isset($nodes_to_load['node'])) {
  $nodes = entity_load('node', array_keys($nodes_to_load['node']));

  foreach ($nodes as $node) {
  $node-&gt;field_myother_field[$node-&gt;language][]['value'] = '500';
  $node-&gt;title = "retest the test";
  node_save($node);
 }
}
 else {
  print "no nodes to load";
}


UPDATE: When I try to change the field by going into the admin panel, and simply typing in a new value I get a "The content on this page has either been modified by another user, or you have already submitted modifications using this form. As a result, your changes cannot be saved" error.
I suspect you don't have $node->language set, or perhaps the empty [] is causing trouble.

Try:

$result = $query-&gt;execute();
if (isset($result['node'])) {
  $nodes = entity_load('node', array_keys($result['node']));
  foreach ($nodes as $node) {
    // Set node language to default, if not set
    $node-&gt;language = isset($node-&gt;language) ? $node-&gt;language : LANGUAGE_NONE;
    $node-&gt;field_myother_field[$node-&gt;language][0]['value'] = '500';
    $node-&gt;title = 'retest the test';
    node_save($node);
  }  
}else {
  drupal_set_mesage('no nodes to load');
}


Using entity_metadata_wrapper

$result = $query-&gt;execute();
if (isset($result['node'])) {
  $nodes = entity_load('node', array_keys($result['node']));
  foreach ($nodes as $node) {
    $node_wrapper = entity_metadata_wrapper('node', $node); // Get node wrapper
    $node_wrapper-&gt;field_my_other_field-&gt;set('500'); // Set field value
    $node_wrapper-&gt;save(); // Save entity
  }
}else {
  drupal_set_mesage('no nodes to load');
}