How to get the original value of a field that is inside a field collection? I can get the entity reference field node id from my field collection like this:

function mymodule_node_update($node){

    if ($node-&gt;type == 'article'){    

    $node_wrapper = entity_metadata_wrapper('node', $node);

        $before = array();

        foreach ($node_wrapper-&gt;field_collection_ingredients-&gt;value() as $key =&gt; $field_collection_wrapper) {

          $before[$key] = $field_collection_wrapper-&gt;field_ingredient[LANGUAGE_NONE][0]['target_id'];

        } 
  }


Doing: 

$before[$key] = $field_collection_wrapper-&gt;original-&gt;field_ingredient[LANGUAGE_NONE][0]['target_id'];


Causes an error.



Basically I have an entity reference, which allows unlimited values, inside the the field collection.

When someone removes a value from the entity reference field, I need to know which value was removed as I need the Node ID to update that node that was removed from the entity reference.
Try comparing field_collection_ingredients field value of $node-&gt;field_collection_ingredients[LANGUAGE_NONE] and $node-&gt;original-&gt;field_collection_ingredients[LANGUAGE_NONE]‌​, this will give exactly which field collection was removed, you can then try loading that field collection (see note below) and then load $fc-&gt;field_ingredient[LANGUAGE_NONE][0]['target_id']; field value to update Node referenced in field_ingredient field.

Note: If your node does not has revision enabled, the removed field collection will be removed from Drupal database as well, which will cause the error when trying to load the Field Collection Entity. So you might need to enable revision for your main node, to make sure that if field collection is removed from field_collection_ingredients field, it will not get removed from Database.