Migrate plugin migration_lookup : dynamic migration id &quot;node_a_migration&quot; is the migration ID of nodes of type &quot;node_a&quot;
&quot;node_b_migration&quot; is the migration ID of nodes of type &quot;node_b&quot;
I'd like to use either &quot;node_a_migration&quot; or &quot;node_b_migration&quot; as a migration_lookup depending on other field value.
The source (not a drupal site, entities of content A and content B can have the same id, because stored in different tables) :
[
  ['entity_type' =&gt; 'content_a', 'entity_id' =&gt; 123],
  ['entity_type' =&gt; 'content_b', 'entity_id' =&gt; 123],
]

The migration config :
process:
  pseudo_field_migration_id:
    plugin: static_map
    map:
      content_a: node_a_migration
      content_b: node_b_migration
    source: entity_type
  field_entity_reference:
    plugin: migration_lookup
    migration: '@pseudo_field_migration_id'
    source: entity_id

There is no error when running the migration, but the field_entity_reference is not populated.
It works if I manually replace '@pseudo_field_type_id' by node_a_migration
Any idea how to make it work ?
Thank you!
As @Hudri suggested, I've created my own process plugin (extending MigrationLookup plugin):
my_module/src/Plugin/migrate/process/CustomMigrationLookup.php

namespace Drupal\my_module\Plugin\migrate\process;

use Drupal\migrate\Plugin\migrate\process\MigrationLookup;
use Drupal\migrate\MigrateExecutableInterface;
use Drupal\migrate\Row;

/**
 * @MigrateProcessPlugin(
 *   id = &quot;custom_migration_lookup&quot;
 * )
 */
class CustomMigrationLookup extends MigrationLookup {
  
  public function transform($value, MigrateExecutableInterface $migrate_executable, Row $row, $destination_property) {
    // We set the migration id based on the field configured in &quot;migration_id_source&quot;
    $this-&gt;configuration['migration'] = $row-&gt;getDestinationProperty($this-&gt;configuration['migration_id_source']);
    // We continue with the standard migration_lookup process
    return parent::transform($value, $migrate_executable, $row, $destination_property);
  }

}


The migration config :
process:
  pseudo_field_migration_id:
    plugin: static_map
    map:
      content_a: node_a_migration
      content_b: node_b_migration
    source: entity_type
  field_entity_reference:
    plugin: custom_migration_lookup
    migration_id_source: 'pseudo_field_migration_id'
    source: entity_id