This module provides integration of 'Rules' and 'Webform' modules for Drupal 9/10. It enables site builders and administrators to get access to webform submission data from rules. Also it provides possibility of altering and removing webform submissions from rules.

Recommended modules

'Rules User Fields' enables to get access to all fields of a User entity from Rules. It makes possible to create and manage users accounts with 'Rules' and 'Webform' modules.

'Rules Data Exchanger' enables to exchange data between Rules and rules Components in Drupal 8. It's allows to store any data of a some Rule and then use them in others Rules or Components.

Alternative modules

If you don't have to altering of a webform submission data, then you can use 'Rules Token' module.
The 'Webform Content Creator' module enables to create nodes after submitting webforms and populate nodes fields with webform submission values (the 'Rules' module is not needed).

Uses

Read a webform submission

To access webform submission data from a rule you need to do two things:

1. Select the 'Webform submit' event from the 'React on event' listbox.

img-1

2. Select necessary webform from the 'Webform' listbox that will appear below.

img-2

After that will be available two new variables: 'webform_fields' and 'webform_info'. You can use them in your rule actions and conditions.

img-3

'webform_fields' contains values of webform fields

img-4

'webform_info' contains additional information like submission date, author and so on.

img-5

To investigate them it's conveniently to use 'Data selection mode'. Therefore click on 'Switch to data selection mode' button in your condition or action page. Then type variable name with dot at the end, like this: 'webform_fields.' After that you will see all webform fields and you can choose any of them. But you can also use 'Direct input mode'. For instance, if you need to get the value of 'message' field you can use Twig syntax like this: {{ webform_fields.message }}

Alter a webform submission

To alter a webform field value you need to do the following:

1. Add 'Set webform field value' action.

img-6

2. Select a webform field you want to alter.
Keep in mind that it's possible to select a webform field only in 'Data selection' mode.
Therefore click on 'Switch to data selection' button before you start typing.
Then type the name of a necessary webfrom field.
For instance, if you want to alter the value of 'name' field, type the following:
webform_fields.name

img-7

3. Input a new value of webform field into the 'VALUE' field.
Remember that you can completely replace field value as well as to complement existing value. Let's say you want to complement the value of field 'name' with 'Sir'. Then stay in the 'Direct input' mode and type the following:
Sir {{ webform_field.name }}

Delete a webform submission

To delete a webform submission from a rule use 'Delete webform submission' action.

img-8

Known issues

1. The module doesn't work with Rules components (actions and variables are not available). To provide a webform data to components you can use 'Rules Data Exchanger' module.

2. Before adding 'Delete webform submission' action ensure that you save previous changes of your rule (click on 'Save' button).

Supporting organizations: 

Project information

Releases