Programmatically node update while saving node How can I update the value of the field in the nodes while save/update the node?
When you save/update the node value from the field was taken and save in the same field in the other nodes.
I tried to do it hook_ENTITY_TYPE_presave()

$nodes = Node::loadMultiple($nids);
foreach ($nodes as $node) {
  $node-&gt;set('name_field', $value);
  $node-&gt;save();
}


But this causes infinite recursion
You can use hook_entity_presave

function hook_entity_presave(Drupal\Core\Entity\EntityInterface $entity) {

    if ($entity-&gt;getEntityTypeId()=='node'){
        $value="099545";
        $entity-&gt;set('name_field', $value);
    }
}