I have a batch function that is called when the user has submitted the webform.

Is there a function where I can assign the task to a specific user or role using a batch function?

function maestro_hook_is_draft($processID, $queueID) {
  $sid = MaestroEngine::getEntityIdentiferByUniqueID($processID, 'submission');
  if ($sid) {
    $webform_submission = \Drupal\webform\Entity\WebformSubmission::load($sid);
    if ($webform_submission) {
      if ($webform_submission->isDraft()) {
        //if webform is draft, assign task to user
        /* NEED HELP HERE */
  return TRUE;

The closest method Maestro uses to assign functions is productionAssignments() in MaestroEngine.php.

 * Using the queueID, the task's machine name and the template machine name, we assign the task 
 * using the appropriate method defined in the template.
 * @param string $templateMachineName  Machine name of the template
 * @param string $taskID Machine name of the task
 * @param int $queueID  The ID of the queue entity this task belongs to
protected function productionAssignments($templateMachineName, $taskID, $queueID) {
  // ...
  $assignments = explode(',', $assigned);
  foreach($assignments as $assignment) {
    $thisAssignment = explode(':', $assignment);
    // [0] is user, role etc.
    // [1] is how such as fixed or by variable. 
    // [2] is to whom or which variable
    if ($thisAssignment[1] == 'fixed') { //assigned by fixed name
      $values = array (
        'queue_id' => $queueID,
        'assign_type' => $thisAssignment[0],
        'by_variable' => 0,
        'assign_id' => $thisAssignment[2],
        'process_variable' => 0,
        'assign_back_id' => 0,
        'task_completed' => 0,
      $prodAssignments = \Drupal::entityTypeManager()->getStorage('maestro_production_assignments')->create($values);
  • In Maestro all you really need is the $processID because then you can get pretty much do everything - try to loaded it where you have /* NEED HELP HERE */ via \Drupal::entityTypeManager()->getStorage('maestro_process')->load($processID); then you can get the template meta if you know that annd the $queueID you can guess at the next $queueID and then create the $prodAssignment or can create your own task type because there just plugins see patch here drupal.org/project/maestro/issues/3067457 on how to make a custom task type
    – taggartJ
    Dec 16, 2020 at 4:41


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.