Get all submissions from specific webform

by Ronnie   Last Updated January 12, 2018 22:07 PM

I am trying to load webform submissions by a particular webform sign_up.

Using Query webform submissions, this does get me all the IDs associated and I can load the data using

$query = \Drupal::entityQuery('webform_submission')
  ->condition('webform_id', 'sign_up');
$result = $query->execute(); // Gives me IDs associated with the "sign_up" webform.

$storage = \Drupal::entityTypeManager()->getStorage('webform_submission');
$submissions = $storage->loadMultiple($result);
$submission_data = array();
foreach ($submissions as $submission) {
  $submission_data[] = $submission->getData();
}
// $submission_data now contains all the submissions from "sign_up" webform.

Is this the correct way of getting the submissions? I would think Webform comes with some sort of API to query the submission results.

I also tried: https://www.drupal.org/project/webform/issues/2902682 but ended up with an empty array.

Tags : 8 webform


Related Questions


Webform Rules - Create a Drupal User

Updated November 24, 2017 14:07 PM


Hide webform after the user's first submission

Updated May 16, 2017 17:07 PM

How to get instant result after submitting webform?

Updated September 14, 2017 12:07 PM