Update a field based on value of another field in node edit form
Drupal 7:

Create a custom module. This module should implement hook_node_insert and hook_node_update. Both functions will have almost identical code, and it should go something like this:

/**
 * Implements hook_node_insert()
 */
function mymodule_node_insert($node) {
  if ($node-&gt;type == 'my_node_type') {
    // Set the $value variable with value you wish
    // to insert to the referenced node.
    $field = field_get_items('node', $node, 'field_whatever_it_is');
    $value = $field[0]['value'];

    // Grab the referenced node's nid.
    $field = field_get_items('node', $node, 'field_nodereference_field_name');
    $ref_nid = $field[0]['value'];

    // Load the referenced node into a variable. Avoid cached nodes.
    $ref_node = node_load($ref_nid, NULL, FALSE);

    // Update the referenced node with $value
    $ref_node-&gt;field_to_update[0]['value'] = $value;

    // Save the referenced node
    node_save($ref_node);
  }
}


If you just want to update the referenced node's node reference field with the current node's nid then you can also just use a module called Corresponding Node References