Migration Custom Plugin Return Value I have a migration and it is very simple. I have a CSV file of employee number and years of service. I have added the two fields to the users in the system and populate them when the users have been added. I now I have a yearly file to update the years of service value. I created the below Migration to import/update the seniority:

id: seniority_import
label: Seniority CSV file import
description: Seniority CSV file import
migration_group: timeoff
migration_tags:
  - seniority_timeoff
langcode: en
status: true
dependencies:
  enforced:
    module:
    - timeoff_seniority
source:
  plugin: csv
  track_changes: true
  path: "/Users/rfulcher/Downloads/Seniority2017-2.csv"
  keys:
    - EMPNO
  column_names:
    0:
      EMPNO: "Employee Number"
    1:
      SENIORITY: "Employee Seniority"
process:
  uid:
    -
      plugin: user_lookup
      source: EMPNO
      value_key: field_employee_id
      entity_type: user
      bundle: 1
      bundle_key: status
      ignore_case: true
    -
      plugin: skip_on_empty
      method: row
      source: uid
      message: 'no empno found'
  field_employee_id: {}
  field_seniority: SENIORITY
destination:
  plugin: entity:user
  overwrite_properties:
    - field_seniority


I also create the custom process plugin to lookup the uid of the user using the employee number

   &lt;?php

namespace Drupal\timeoff_seniority\Plugin\migrate\process;

use Drupal\migrate\ProcessPluginBase;
use Drupal\migrate\MigrateExecutableInterface;
use Drupal\migrate\Row;

/**
 * Returns a user if exists.
 *
 * Example:
 *
 * @code
 * process:
 *   field_your_field_name:
 *     -
 *       plugin: your_plugin_name
 *       source: some_source_value
 * @endcode
 *
 *
 * @see \Drupal\migrate\Plugin\MigrateProcessInterface
 *
 * @MigrateProcessPlugin(
 *   id = "user_lookup"
 * )
 */
class UserLookup extends ProcessPluginBase {
  /**
   * {@inheritdoc}
   */
  public function transform($value, MigrateExecutableInterface $migrate_executable, Row $row, $destination_property) {

    $user_uid = $this-&gt;getUserByEmpNo($value);

    if ($user_uid == FALSE){
      drush_print('usernotfound for ' . $value . ' returning 0');
      return 0;
    } else {
      drush_print('userfound:'.$user_uid.': for ' . $value);
      return $user_uid;
    }
  }

  protected function getUserByEmpNo($employeenumber) {

    $id = \Drupal::entityQuery('user')
                  -&gt;condition('field_employee_id', $employeenumber)
                  -&gt;execute();
    $users =  \Drupal\user\Entity\User::loadMultiple($id);

    if (!empty($users)) {
      foreach ($users as $user) {
        $update_id = $user-&gt;id();
        return $update_id;
      }
    } else {
      return FALSE;
    }
  }

  public function prepareRow($row) {

  }
}


The import runs and I find the uid and return the value but it is like the migration ignores it and skips the row.

Am I missing something. I have worked on this way too long and this should be simple but I must not be understanding how this is supposed to work or something. I am totally at a loss.

Simple csv file with just two fields empno, seniority. Nothing fancy. Any help with this would be appreciated, thanks very much.

Thanks
I think the problem might be the source on the skip_on_empty plugin. It looks like you're trying to refer to the result of the previous plugin to obtain the destination uid; I don't think you can do that until after all plugins have run on the field.

Even if you can make that reference, there's a special syntax for referring to destination fields on the source side, which is an @ symbol plus the field name (e.g. '@uid').

A solution that should remove all doubt would be to load the uid in a fake field, and re-use it for the proper destination field. For example:

process:
  _uid:
    plugin: user_lookup
    source: EMPNO
    value_key: field_employee_id
    entity_type: user
    bundle: 1
    bundle_key: status
    ignore_case: true
  uid:
    plugin: skip_on_empty
    method: row
    source: '@_uid'
    message: 'no empno found'


Of course that might be wrong, and you may just have meant to use EMPNO instead of uid for the source, in which case you should just fix that and move the skip_on_empty plugin so it runs first, saving yourself DB queries with empty conditions.