What I want to do is quite simple in itself: when a node is flagged, I want to fill a field of that node with a certain fixed value.

* I got the rule started with "after saving new flagging". If I take only this event and use a "display message" as an action, the rule works and the message is displayed.

* If I add a condition "entity is of bundle" to specify the flag, the rule still works, the message is still displayed.

* Even if I add an action "set a date value" and I choose "flagging.flagged_entity.entity.title.value" as data, I can set the title of the node to whatever I want.

I cannot, however, select the field I want to fill... I know I have to add a condition "entity is of bundle" first, but it does not work. Whenever I try to do so and pick "flagging.flagged_entity" in the data selector, I get an error page after saving the condition...

"Entity has field" is also not working. I can add that condition, but it does not offer me the chance to add the field I want to fill. Even stranger: I can add that condition, but when I choose to edit it and I save it again, even without making any changes, I get an error.

* When I choose "flagging.flagged_entity" as entity, it gives me the error: "Expected a entity data type for context Entiteit but got a list data type instead."
* When I choose "flagging.flagged_entity.entity" as entity, it gives me the error: "Expected a entity data type for context Entiteit but got a entity_reference data type instead."

(Btw, I also tried with "q_levjan" as field and "field_q_levjan" as the name of the field to check for.)

Is this a bug? Or am I doing something wrong??

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Jan_MSK created an issue. See original summary.

shabana.navas’s picture

FileSize
2.52 MB

Not sure if you're still struggling with this issue, but the 'Set Data Value' on New Flagging does work. I just re-created the same steps as you mentioned, and actually didn't even use the 'Entity has field'/'Entity is of bundle' conditions and it still worked. But what I did notice though, I had to clear cache every time I made a change to the Rules conditions or actions for it to take affect and I don't have caching enabled either. But the setting of the data value does work.

See attached gif.

jweirather’s picture

Regarding the cache clear required on rule edit, there is an open issue/patch for it, here:

https://www.drupal.org/project/rules/issues/2816033

TR’s picture

Status: Active » Closed (cannot reproduce)

@SuperStes:

In #2 @shabana.navas provided a very nice demonstration which shows that this does indeed work properly. I don't know whether this helped you or not, because you never replied to her post.

Regardless, it's evident that this is not a bug. But if you're still having problems with it feel free to reopen this issue with further details.