Problem

Notification emails need to sent to all users assigned to specific role.

Solution

Allow 'To', 'Cc', and 'Bcc' email addresses to be populated using selected roles.

Tasks

  • Update admin settings form. (email_roles)
  • Update admin settings scheme. (email_roles)
  • Refactor recipient email element.
  • Update email handler configuration form. (EmailWebformHandler::buildConfigurationForm)
  • Add 'Email roles' checkbox with hide/show logic. (to_roles, cc_roles, bcc_roles)
  • Update email send method (EmailWebformHandler::getMessage)
  • Update email summary to support selected roles.
  • Add custom support for 'authenticated' role.
  • Make sure roles are rechecked before sending email.
  • Update email debugger.
  • Write update hook to update all existing email handlers.
  • Write tests.

Notes

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

jrockowitz created an issue. See original summary.

jrockowitz’s picture

Issue summary: View changes

  • jrockowitz committed 11961c2 on 2856842-email-by-role
    Issue #2856842: Allow emails to be sent to selected roles
    

  • jrockowitz committed 2270400 on 2856842-email-by-role
    Issue #2856842: Allow emails to be sent to selected roles
    

  • jrockowitz committed 43983cb on 2856842-email-by-role
    Issue #2856842: Allow emails to be sent to selected roles. Write tests.
    
jrockowitz’s picture

Status: Active » Needs review
FileSize
31.47 KB

Status: Needs review » Needs work

The last submitted patch, 6: allow_emails_to_be_sent-2856842-5.patch, failed testing.

  • jrockowitz committed 938d037 on 2856842-email-by-role
    Issue #2856842: Allow emails to be sent to selected roles. Write tests.
    
jrockowitz’s picture

Status: Needs work » Needs review
FileSize
31.65 KB

  • jrockowitz committed e3754c6 on 8.x-5.x
    Issue #2856842 by jrockowitz: Allow emails to be sent to selected roles
    
jrockowitz’s picture

Status: Needs review » Fixed
kclarkson’s picture

Jake,

After a few different token combinations I was able to get the feature working. Here are a couple of issues that I am seeing.

1. The token suggestion should include the "mail" part. Right now the token suggestion is: [webform_role:name] it should read - [webform_role:name:mail]

I know you put it in the notes but it was a little difficult to find. I know for a lot of site builders they are probably expecting a check box but I know this isn't necessary. Just a better description in the token suggestions. Also the example in the notes has the format with the curly braces [webform_role:{name}:mail] . The curly braces can throw you off. Seeming that tokens in Views is now TWIG, the curly braces I thought were a part of the twig token.

2. The email handler is setup to fire on the "creation" of submission. We need the handler to also fire on 'update' of submission.

The use case for the application review is to be able to have a hidden field on a submission, allow a person to change that field and when that field is changed the email handler fires and emails out.

  • jrockowitz committed e3754c6 on 2856842-email-by-role-v2
    Issue #2856842 by jrockowitz: Allow emails to be sent to selected roles
    
jrockowitz’s picture

1. I am just going to remove the ':mail' from webform role token and display all available roles. (ie [webform_role:authenticated], [webform_role:administrator], etc...)

2. Needs to addressed in new ticket which I can create.

  • jrockowitz committed 75a4269 on 2856842-email-by-role-v2
    Issue #2856842 by jrockowitz: Allow emails to be sent to selected roles
    

  • jrockowitz committed 64608b7 on 8.x-5.x
    Issue #2856842 by jrockowitz: Allow emails to be sent to selected roles
    
jrockowitz’s picture

@kclarkson I committed the update. Please review.

jrockowitz’s picture

Status: Needs review » Fixed
kclarkson’s picture

@jake,

Much and improved sir.

1. The tokens are just a copy and paste for the user-role - Awesome!!!
2. Providing checkboxes for when to send emails (updat, delete, submission etc.) provides a nice and clean touch. - Awesome!!!

This is perfect for quite a little mini workflow based on webform fields. I can now have the application use a field at which I can set visible to just a Pre-Reviewer. After the application submission I can fire a email confirmation to the end user, send an email to the "Pre-Reviewer", then the pre-reviewer can change a status field on the submission and then it fires an email to everyone with the "Reviewer Role" that says available for review.

Fixed Fixed and Fixed!

jrockowitz’s picture

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

CLKeenan’s picture

Aw man. This is exactly what I need for the D7 version of webform! Any plans on backporting this to D7.4?

sorin_cocorada’s picture

Hello,
Would it be possible, using this approach, to send emails to a dynamically generated role?

Use case: I want to send emails (when the webform is submitted, updated and so on) to a role which depends on a webform submission value.

Thanks!

demonde’s picture

If I get it right, there is no way to send an email to a submitter that has a specific role by this function. Emails will be send to all users that have a specific role here.