Use case: a small site where I want to warn all users by mail whenever a new content of a particular type is created. I thought I would try Rules+Actions to handle this.

I'm working on a vanilla Drupal 8 test site on my workstation, so there is just "Article" and "Basic Page".

I've installed the Rules module ok. I've looked at several videos explaining how this works in Drupal 7 and they looked reasonable straightforward. Now I'm trying to do something in D8 and finding it less than obvious.

Specifically, I've created the rule to fire when new content is created, and now I'm on a page editing Condition, where I want to specify that the node type is "Article". Using "Data selection" mode in the "Entity" field I select "node.type". This seems logical, but what on earth do I put in "Type"? No matter what I put I get a message something like this: "Data selector node.entity for context Entity is invalid. Unable to apply data selector 'entity' at 'entity' " - which is about as unexplicit as you can get.

Maybe I'm jumping the gun and Rules is not usable yet? Or maybe I've just not understood it at all...

But I would really appreciate if somebody could explain to me what seems quite straightforward in principle. How do I add a condition to my Rule that will cause the rule to fire only on a specific content type?


Answering the "what do I put in the 'type' box?" question, the answer appears to be the same as for D7 - that is, the same status you'd pass to drupal_set_message().

This gives you options of:

  • status
  • warning
  • error

As to the state of D8 and specifically D8 rules, I share your pain - and it's nine months since you asked the question!


I don't know what the status of Rules was when this question was first asked, but the following is a complete example of how to use the "Node is of type" condition to check if a newly-created node is an article. I have had a similar rule working on my site for more than two years now - Rules has definitely been working and usable since then for things like this.

langcode: en
status: false
dependencies: {  }
id: new_article_created
label: 'New article created'
    event_name: 'rules_entity_insert:node'
description: 'Issue #2852342-16: Shows a system message when a new node of type ''article'' is created.'
tags: { }
config_version: '3'
  id: rules_rule
  uuid: f8e466d6-51d6-41ea-93f1-34436470f3c3
    id: rules_and
    uuid: 7776a869-e0c6-4499-b09e-da727722213e
        id: rules_condition
        uuid: 6bf893f5-7bcf-420c-9a62-7e1cb9a884f6
            - article
          node: node
            rules_tokens: {  }
        provides_mapping: {  }
        condition_id: rules_node_is_of_type
        negate: false
    id: rules_action_set
    uuid: f0bcccfd-685f-4a74-a4fd-0d36b540037a
        id: rules_action
        uuid: ec599dbc-cb40-448b-b37b-129d956c2eb7
          message: '<b>New article created:</b> {{ node.title }}'
          type: status
          repeat: false
        context_mapping: {  }
            rules_tokens: {  }
            rules_tokens: {  }
            rules_tokens: {  }
        provides_mapping: {  }
        action_id: rules_system_message

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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