Target audience: Site Administrators, Site Managers
In the Web Management System (WMS), tokens make it possible to reference data provided by users when filling in a webform.
In this article:Tokens can be used to:
If an email template was created, view a complete list of available tokens by going to the E-mails settings on the WEBFORM tab , clicking Edit on a template, and then clicking on the Browse available tokens link beneath the E-MAIL TEMPLATE text area.
This article only covers Current user and Submission tokens.
The Webform Calculator module also makes use of tokens in Formula fields. However, these tokens can only be used to reference Number and Textfield components and have a different structure. To learn more about how tokens are used in Formulas, see Webform Calculator (Formula) module in the WMS.
Current user tokens can be used to obtain information about the user, provided that the form requires authentication and the user is logged in. Below is a selection of tokens:
Name |
Token |
Description |
Example* |
---|---|---|---|
Name |
[current-user:field_mcgill_user_name] |
McGill username |
Dylan McKay |
Department |
[current-user:field_mcgill_user_department] |
McGill department to which the user belongs |
Student Services |
|
[current-user:mail] |
McGill email address |
dylan.mckay@mcgill.ca |
IP address |
[current-user:ip-address] |
User's IP address |
132.456.789.101 |
Last login |
[current-user:last-login] |
Date and time user last logged in |
Fri, 10/20/2020 - 09:46 |
McGill ID |
[current-user:field_mcgill_user_id] |
User's McGill ID |
260123456 |
Roles |
[current-user:roles] |
User's role in the WMS |
authenticated user, McGill Staff and Faculty |
Telephone |
[current-user:field_mcgill_user_phone] |
McGill phone number |
(514) 398-1234 |
Title |
[current-user:field_mcgill_user_title] |
McGill title |
Event Coordinator |
Current user tokens can be used with most components, particularly in the Default value and Description fields.
For instance, to create a form where the user's name is automatically filled in and cannot be changed, follow these steps:
Current user tokens can be used in webform emails. Please be sure to follow the security best practices outlined for the collection of confidential data (including McGill ID) in Create a Webform in the WMS.
Submission tokens can be used to relay information collected from a form, when the user clicks on Submit or Next in a multi-page form where drafts are saved.
Below is a selection of submission tokens:
Name |
Token |
Description |
Example* |
---|---|---|---|
Date submitted |
[submission:date] |
Date the webform was first saved as draft or completed by the user |
Mon, 05/07/2020 - 14:28 |
IP address |
[submission:ip-address] |
The User's IP address |
132.456.789.101 |
Serial number |
[submission:serial] |
The serial number of this webform submission |
1** |
Submitter |
[submission:user] |
The user that submitted the webform result |
dylan.mckay@mcgill.ca |
URL |
[submission:url] |
The submission's URL |
https://www.mcgill.ca/it/node/1234/submission/5678 |
Webform submission values |
[submission:values:?] |
Webform tokens from submitted data. Replace the "?" with the "form key", including any parent form keys separated by colons |
See: Structure of a Webform Submission values token |
*Default number for first submission
To include submitted form answers in emails or confirmation pages, use the Webform Submission values token.
The typical token structure is [submission:values:?] where ? is the form key.
The form key is the machine-readable name of the component which is being referenced. For instance, the submission token for a field labelled First Name, with the default form key first_name, would be [submission:values:first_name]. The form key can be seen by going to Webform > Form components.
If this field is nested inside a fieldset labelled User Information with the default form key user_information, then the token would be: [submission:values:user_information:first_name]
Webform Submission values tokens can be further refined by appending additional keys.
This is the key for a specific question in a grid component. For example, a grid labelled Student Feedback with the question: How would you rate your course?
would have the token: [submission:values:student_feedback:course]
This is the key for a specific option in a grid or select component. For example, a grid labelled Student Feedback with the option:
would have the token: [submission:values:student_feedback:excellent]
Component type |
Label |
Form key |
Token |
User entry |
Display |
---|---|---|---|---|---|
Textarea |
Comments |
comments |
[submission:values:comments:nolabel] |
Awesome course, awesome instructor! |
Awesome course, awesome instructor! |
Component type |
Label |
Form key |
Token |
User entry |
Display |
---|---|---|---|---|---|
Textarea |
Comments |
comments |
[submission:values:comments:label] |
Awesome course, awesome instructor! |
Comments |
Component type |
Label |
Form key |
Token |
User entry |
Display |
---|---|---|---|---|---|
Textarea |
Comments |
comments |
[submission:values:comments:withlabel] |
Awesome course, awesome instructor! |
Comments: Awesome course, awesome instructor! |
Component type |
Label |
Form key |
Token |
User entry |
Display |
---|---|---|---|---|---|
Select options |
Rating |
rating |
[submission:values:rating:key] |
5|Excellent |
5 |
Use Webform Submission tokens to include answers submitted by users in webform emails and confirmation pages.
For example, to include the name of an event for which a user is registering in an email from the form, do the following:
Submitted values are:
[submission:values]