According to the documentation, we can "Any textfield, select, or hidden form element may be selected as the subject for e-mails." However, no matter what we do, we cannot seem to get the values to appear in the custom subject.

Webform email subject

Lower on the screen it mentions using submission tokens, but the only one I can get to work is the [submission:values] token, and then only in the body field. I have never gotten the [submission:values:?] token to work no matter what I used in place of the "?"

submission tokens

We want to be able to have the subject include the custom text and a field's input value for one of the webform's fields.

Are we misunderstanding how this works?

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

DanChadwick’s picture

Status: Active » Fixed

The documentation you reference is probably referring to the "FROM" address for the e-mail, not the subject. It should be updated.

Any component that has a token may be used in the subject or body of the e-mail. For example, if you have a fieldset with a field key of 'address' and within that a textfield with field key of 'last_name', the token for that would be [submission:values:address:last_name].

If this isn't working, then perhaps something else is not configured correctly in your installation. Carefully check the spelling of your token, including the field key (which is defined in the component itself). Are other non-webform tokens working properly (such as the current user's name)?

You can also put these tokens in the confirmation message. You can then test out your tokens there, if needed.

Beyond that, I have no idea what might not be working. You'd have to hire a developer to debug what's going on. Given the number of webform installations that use token, I don't think anything is broken within webform itself because we don't have a crush of bug reports.

Good luck and post back with what you eventually figure out.

drewpy42’s picture

I've used [submission:values:patron_name] (patron_name is the field that I want to put into the subject line with some other text) in the subject and the body and got only blanks on the email subject. If I select the field from the list, then I get the value but my users are wanting to have the subject read "Tech Squad Help Request for " and then the patron's name that was typed into the Patron Name box.

The only time I've gotten anything from the Token part is when I use only [submission:values], [submission:user], and [submission:date:long]. I was wondering if it was something on our end. I'm not sure what could be interfering, but it is possible. We have the following modules installed that interface directly with webform content:

  • Form builder for Webform UI
  • Webform
  • Webform Template
  • Entity Tokens
  • Tokens
  • Token Tweaks
DanChadwick’s picture

I'd try disabling all those modules, except token.

drewpy42’s picture

Thanks! I inherited the website, so I'm not sure which modules are actually in use. Thankfully, I have a development server if things blow up. Appreciate the fast response.

Status: Fixed » Closed (fixed)

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

nsshrinivasan’s picture

Version: 7.x-4.8 » 7.x-4.12
Category: Support request » Bug report

Im facing the same issue while trying to display a hidden field in the confirmation message. In my case the confirmation message displays in a modal form. It looks like the submission tokens are not being interpreted while it is in a modal form screen.

here generated_code is a form_key in my form which is a hidden field. I'm using hook_webform_submission_presave($node, &$submission) hook to generate the value of the hidden field generated_code and want to display it to the user on the confirmation screen.

[submission:values:generated_code]

nsshrinivasan’s picture

The issue was with modal forms code and bolded part code fixes it.

 if ('<confirmation>' == $node->webform['redirect_url']) {
        // Use confirmation message if set, default text otherwise.
        // See webform/templates/webform-confirmation.tpl.php.
      <strong>  $submission = webform_get_submission($node->nid, $form_state['values']['details']['sid']);
        $message = (empty($node->webform['confirmation'])) ? t('Thank you, your submission has been received.') : check_markup(webform_replace_tokens($node->webform['confirmation'], $node, $submission), $node->webform['confirmation_format'], '', TRUE);</strong>
        $confirmation = '<div class="webform-confirmation">' . $message . '</div>';
        $confirmation .= ctools_ajax_text_button(t('Close'), 'modal_forms/nojs/dismiss', t('Close'));
        $output[] = ctools_modal_command_display($title, $confirmation);
      }
sic’s picture

I have the same issue with a simple text field inside a fieldset: [submission:values:fieldsetkeyname:fieldkeyname] is not working. No fancy modules at all :/

flaviovs’s picture

Version: 7.x-4.12 » 7.x-4.14

I have the same issue with a simple text field inside a fieldset: [submission:values:fieldsetkeyname:fieldkeyname] is not working. No fancy modules at all :/

Confirmed, [submission:values:fieldsetkeyname:fieldkeyname] alone is not working here (in the email template).

As a workaround, use [submission:values:fieldsetkeyname:fieldkeyname:nolabel].

praveen_91’s picture

Hi, All
i'm using Drupal 7.56 and webform 7.x-4.15.
Use this [data:your_name-value] "your_name" is field_key.
It's work for me
thanks

avinash_thombre’s picture

Hi Praveen_91,

I'm using the same drupal 7 and webform versions but still the its not working out for me. Use of [data:your_name-value] does not print any values but only blank space. I'm using modal form window for webform submission. Any suggestion how can I proceed?

avinash_thombre’s picture

[submission:values:FIELDSET_FORM_KEY:FIELD_KEY] is working for me. Don't include any wrapper_key or markup_key and keep it simple(like [submission:values:fieldset_key:field_name]);if present in the nested structure. Or you can try permutation-combination of [submission:values:fieldset_key:markup_key:wrapper_key:field_name:withlabel], it will definitely work.
Best of luck!