Case: using Rules module, when a user account is cancelled, create a new node of type Archive and (a) copy select data from that account to the new node of type Archive, and (b) copy select data from a single node of type XYZ authored by the cancelled user to the new node of type Archive.

I have this rule:

After a user account has been deleted
Create a new entity
(set data values here)
Save entity

In Actions, the new node created is of type Archive. In between creating and saving this new node, data values are set (i.e. "Set data value") on it. The values are derived from the account being cancelled.

However, how can I access a node of type XYZ authored by this account, and use that to also set data values on the new node of type Archive? There seems to be no way to access the fields of XYZ in the Data Selector. The available fields pertain only to the account, and not to content authored by that account.

As a comparison, in Views I would establish a Relationship to open up access to fields of related entities. What's the equivalent in Rules?


1 Answer 1


You can use the Views Rules module, as further detailed below.

1. About the Views Rules module

The Views Rules module makes Views data available in Rules, enabling intuitive rule configuration for dynamic data. Some details from its project page:

... provides two types of elements in Rules, configured with a "Rules" view display:

  • Views loop: A views loop is similar to a regular Rules loop, but allows looping over rows of view results.

    enter image description here

  • Collect view result rows (action): This action collects each variable in all view result rows into list variables for use in Rules.

Tip: When selecting the data type for variables in the view, if the field is an entity identifier (e.g. Node ID), you can set the data type to the entity type (i.e. Node) to directly use the variable in Rules as an entity!

2. Create a view of display type 'Rules'

After you enable the Views Rules module, you can use Views to create a view of your "node of type XYZ authored by this account" (as in your question). Add of view of display type Rules (important, that's the key to make it work!). Here is how you can add such display:

enter image description here

Next configure the row variables, by using the link that says "edit field info", as shown here:

enter image description here

3. Create a rule using the view of display type 'Rules'

Adapt your Rulew Actions, using these guidelines:

  • Use the link that says Add view loop to add a Views loop, and select the "Rules" display created in the previous step.
  • Configure the parameters and variable names.
  • For each node contained in your Views loop (I seem to understand you will only have one), perform whatever Rules Action that fits your requirement, using the variables you configured at the end of the previous step (you may have to revisit the previous step to add more similar variables there if needed).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.