Entity id availability in Custom Field I've created a Custom Field (let's call it 'Reference') whose value requires the Entity Id.

To accomplish that I modify the Field value in the postSave method, like this:

if (!$update) {
  $this-&gt;get('value')
    -&gt;setValue($this-&gt;getCalculatedReferenciaValue());
}

public function getCalculatedReferenciaValue() {
  //...
  $entity = $this-&gt;getEntity();
  $id = $entity-&gt;id();
  $year = date("Y", $date);
  // default format: 'SWAN%s%08dIMOV'
  $format = $this-&gt;getSetting('format');
  return sprintf($format, $year, $id);
}


Then, in pathauto, I use that custom created field, as a token, to generate the path. 

However, for some reason, when creating a node, my custom field still has the default value.

If I then edit and save the node, the custom field (and the auto path) is updated correctly.

Q: Is there a way to update the field value so that it becomes available when generating the autopath for the first time?
For getting the node ID you need to first save the node. For eg:

$node = Node::create([
      'type' =&gt; 'my_content_type',
      'title' =&gt; 'My Title',
      'uid' =&gt; \Drupal::currentUser()-&gt;id(),
      'status' =&gt; 1
]);
$node-&gt;save();
    :
    :

$id = $node-&gt;id();
$year = date("Y", $date);
// default format: 'SWAN%s%08dIMOV'
$format = $this-&gt;getSetting('format');
$node-&gt;field_custom-&gt;value = sprintf($format, $year, $id);
$node-&gt;save();