Pass node field value to view filter in a block
The easiest way to use a view in a block (or anything that uses a build array) is as a render element:

$node = \Drupal::routeMatch()-&gt;getParameter('node');

$current_nid = $node-&gt;id();

$view_arguments = [$current_nid];

 $build['news'] = [
   '#type' =&gt; 'view',
   '#name' =&gt; 'myviewname',
   '#display_id' =&gt; 'block_1',
   '#arguments' =&gt; $view_arguments,
   '#weight' =&gt; 30,
 ];

return $build;


The first argument passed in will be used as your content ID.

If you want to do it all through the UI, you set your contextual filter to pull from the content id.



then if you place a block based on the view, it will pull in from the current node.