Load node by value of a field and update value for another field I'm trying to load a node by a value in a custom field (field_one) to change the value of another custom field (field_two) on that node.

I am using the following code to load the node:

$nodes = \Drupal::entityTypeManager()
      -&gt;getStorage('node')
      -&gt;loadByProperties(['field_one' =&gt; $fieldValue]);


I am then trying to update the value of "field_two" using the following code:

if ($node = reset($nodes)) {

    $node-&gt;set('field_two', 'New value');
    $node-&gt;save();
}


The above results in the error "InvalidArgumentException: Field field_two is unknown... "

It works if I try to set the value of the title ( $node->set('title', 'New value') ) but I can't get it to work for custom fields?
Thanks to the comment by @No Sssweat I realized that I simply needed to specify a content type:

$nodes = \Drupal::entityTypeManager()
      -&gt;getStorage('node')
      -&gt;loadByProperties(['field_one' =&gt; $fieldValue, 'type' =&gt; 'CONTENT_TYPE']);