Workflow sorting Filter Not Working

Created on 24 July 2023, over 1 year ago
Updated 23 November 2023, 12 months ago

Problem/Motivation

Webform submission workflow sorting Filter not working

Steps to reproduce

If the Workflow Steps don't have any data then the submission page filter not working

Proposed resolution

Need to modify WebformSubmissionWorkflowListBuilder.php line no 117: $this->total = (!empty($finalIds))?count($finalIds):1;
//add 1 if a particular filter doesn't have any data.

Remaining tasks

N/A

User interface changes

N/A

API changes

N/A

Data model changes

🐛 Bug report
Status

Active

Version

1.0

Component

Code

Created by

🇮🇳India soumyajit40cs

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @soumyajit40cs
  • 1. Create a Custom Module

    2. Implement hook_help():
    In the custom_submission_filter.module file, add the hook_help() implementation to provide information about the module:

    /**
    * Implements hook_help().
    */
    function custom_submission_filter_help($route_name, \Drupal\Core\Routing\RouteMatchInterface $route_match) {
    switch ($route_name) {
    case 'help.page.custom_submission_filter':
    return '

    ' . t('Modifies the WebformSubmissionWorkflowListBuilder class to handle empty Workflow Steps data.') . '

    ';
    }
    }

    3. Implement hook_webform_submission_filter_query_alter():
    Now, implement the hook_webform_submission_filter_query_alter() hook to override the WebformSubmissionWorkflowListBuilder class behavior. In the custom_submission_filter.module file, add the following code:

    use Drupal\webform\Plugin\WebformHandler\EmailWebformHandler;
    use Drupal\Core\Entity\Query\QueryInterface;

    /**
    * Implements hook_webform_submission_filter_query_alter().
    */
    function custom_submission_filter_webform_submission_filter_query_alter(QueryInterface $query, $form_id) {
    // Get the Workflow Steps data count.
    $workflow_steps_count = count(\Drupal::entityQuery('webform_submission_workflow_step')
    ->condition('webform', $form_id)
    ->execute());

    // If there are no Workflow Steps data, set the total count to 1.
    if ($workflow_steps_count === 0) {
    $query->addExpression('1', 'total');
    }
    }

  • 🇮🇳India soumyajit40cs

    Hi @Aswathy25 ,

    Based on your suggestion I have tried in my system, but it's not working.

  • 🇳🇴Norway gisle Norway

    The code snippet provided by Aswathy25 in comment #2 looks like AI Generated Content.

    Please note that Our policy on AI Generated Content requires those posting such content to:

    • Disclose that AI was used in crafting the code or content.
    • Carefully review and test the output, to ensure it is relevant, and that it works.
    • Provide human intervention to correct inaccuracies, mistakes, or broken code.

    I am a site moderator on Drupal.org and must point out that posting AI Generated Content that violates this policy will result in a ban.

  • This patch is a rewrite of the solution in #5, which works but is less readable.

Production build 0.71.5 2024