Trigger Emails/Handlers on Webform submissions update

Created on 13 September 2018, almost 6 years ago
Updated 2 February 2021, over 3 years ago

Is there a way to trigger the Emails/Handlers, When webform submission has been updated. I'm using webform_mailchimp module for the handler. When I'm submitting a new record, handler is working fine and I can receive the data into my Mailchimp account. I have a function to update the submission via code(custom module). This handler doesn't work, when I update an submission. Following is my code to update the webform submission:

$webform = Webform::load('my_form');
$is_open = WebformSubmissionForm::isOpen($webform);
$sid = 2;

if ($is_open === TRUE) {

    $webform_submission = WebformSubmission::load($sid);

    $webform_submission->setElementData('preferred_date', $form_state->getValue('preferredDate'));
    $webform_submission->setElementData('preferred_time', $form_state->getValue('preferredTime'));

    $errors = WebformSubmissionForm::validateWebformSubmission($webform_submission);

    if (!empty($errors)) {
        drupal_set_message(t('Failed! Please contact the administrator.'), 'error');
    }
    else {
        $webform_submission = WebformSubmissionForm::submitWebformSubmission($webform_submission);
        drupal_set_message(t("Success! ".$webform_submission->id()), 'status');
    }
}

Is there a way to trigger the handler through code(programmatically)?

Thanks,

πŸ’¬ Support request
Status

Closed: works as designed

Version

5.0

Component

Code

Created by

πŸ‡ΈπŸ‡¬Singapore krrishnajee

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

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.69.0 2024