Drupal version: 8.4.2

Steps to reproduce:

Created a new rule with following details:
1) Events: After saving new content
2) Condition: Node is of type
NODE Data selector: node.type
CONTENT TYPES value: page
3) Action: Show a message on the site
MESSAGE value: Rule called for New Content Created
MESSAGE TYPE value: status
REPEAT MESSAGE value: Left Blank Content Created
MESSAGE TYPE value: status
REPEAT MESSAGE value: Left Blank

Actual Result:

Getting The website encountered an unexpected error. Please try again later. but page is created with error message from the log:

TypeError: Argument 1 passed to Drupal\rules\Plugin\Condition\NodeIsOfType::doEvaluate() must implement interface Drupal\node\NodeInterface, instance of Drupal\Core\Field\EntityReferenceFieldItemList given in Drupal\rules\Plugin\Condition\NodeIsOfType->doEvaluate() (line 40 of /opt/app-root/src/modules/rules/src/Plugin/Condition/NodeIsOfType.php) #0 [internal function]: Drupal\rules\Plugin\Condition\NodeIsOfType->doEvaluate(Object(Drupal\Core\Field\EntityReferenceFieldItemList), Object(Drupal\node\Entity\NodeType)) #1 /opt/app-root/src/modules/rules/src/Core/RulesConditionBase.php(69): call_user_func_array(Array, Array) #2 /opt/app-root/src/modules/rules/src/Plugin/RulesExpression/RulesCondition.php(109): Drupal\rules\Core\RulesConditionBase->evaluate() #3 /opt/app-root/src/modules/rules/src/Plugin/RulesExpression/RulesAnd.php(36): Drupal\rules\Plugin\RulesExpression\RulesCondition->executeWithState(Object(Drupal\rules\Engine\ExecutionState)) #4 /opt/app-root/src/modules/rules/src/Engine/ConditionExpressionContainer.php(73): Drupal\rules\Plugin\RulesExpression\RulesAnd->evaluate(Object(Drupal\rules\Engine\ExecutionState)) #5 /opt/app-...

Expected Result:

Should get this message after content is created.

Rule called for New Content Created

Comments

johnreytanquinco created an issue. See original summary.

TR’s picture

Status: Active » Closed (works as designed)

When using the "Node is of type" condition, you have to select "node" in the data selector, not "node.type". You can alternatively use "Data comparison" instead and compare node.type.target_id == page.

Yes, this is a usability issue, and a well-known one - it's being worked on ...

medden’s picture

I get the same error using Drupal 8.5.6 and rules versions : 3.x-dev, * dev-3.x

I get this error even if I don’t add any condition to the rule.

So simply reaction rule: Saving new Content : action : show message.

Yousra14’s picture

The solution found in another thread is:

1) Events: After saving new content
2) Condition: Node is of type
NODE Data selector: node
CONTENT TYPES value: your content type
3) Action: Show a message on the site and dont forget to fill the repeat value with TRUE if you want to have the message shown each time a content is added

the key is in 2) node date selector should be node not node.type
hope this helps