Is there a way to trigger the Emails/Handlers
, When webform submission has been updated. I'm using webform_mailchimp
as a 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. But it doesn't trigger, when I update the same record. 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) {
// Load submission
$webform_submission = WebformSubmission::load($sid);
// Modify submission values
$webform_submission->setElementData('preferred_date', $form_state->getValue('preferredDate'));
$webform_submission->setElementData('preferred_time', $form_state->getValue('preferredTime'));
// Validate submission.
$errors = WebformSubmissionForm::validateWebformSubmission($webform_submission);
// Check there are no validation errors.
if (!empty($errors)) {
drupal_set_message(t('Failed! Please contact the administrator.'), 'error');
}
else {
// Submit values and get submission ID.
$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)?
- Is there a default configuration in the CMS?
Thanks guys,