Set entity reference revision field value? How do I set entity reference revision value for a field? I have two fields, field_test_entity_reference and field_test_entity_revision. field_test_entity_reference is of field type entity reference and field_test_entity_revision is of type entity reference revision. Both are referring to the same content type. I have created a node of this content type and its id is 7747. I am trying the below code and it sets value correctly for the field which is of type entity reference but not for entity revision version.

$node-field_test_entity_reference-&gt;target_id=7747;
$node-field_test_entity_revision-&gt;target_id=7747;
$node-&gt;save();
You need to store also the revision id, see Programmatically append multiple paragraphs to entity reference field on node.

Or simply set an entity, from which the field can get the data it needs in both cases:

$node-&gt;field_test_entity_reference-&gt;entity = $target_node;
$node-&gt;field_test_entity_revision-&gt;entity = $target_node;
$node-&gt;save();