1

How to fetch all the webform drafts saved based on user id?

I tried the below query and it gives me all submission id's but how do I get just the drafts

$query = \Drupal::entityQuery('webform_submission')
      ->condition('uid', 123)
      ->condition('webform_id','test_1');
4

You could try this:

$query = \Drupal::entityQuery('webform_submission')
  ->condition('uid', 123)
  ->condition('webform_id, 'test_1')
  ->condition('in_draft', TRUE);

$entity_ids = $query->execute();

Or via the EntityTypeManager:

/** @var \Drupal\webform\WebformSubmissionInterface[] $submissions */
$submissions = \Drupal::entityTypeManager()
  ->getStorage('webform_submission')
  ->loadByProperties([
    'uuid' => 123,
    'webform_id' => 'test_1',
    'in_draft' => TRUE,
  ]);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.