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??
Comment | File | Size | Author |
---|---|---|---|
#2 | set_data_value.gif | 2.52 MB | shabana.navas |
Flag_8.png | 27.31 KB | SuperStes | |
Flag_7.png | 26.48 KB | SuperStes | |
Flag_6.png | 13.8 KB | SuperStes | |
Flag_5.png | 17.66 KB | SuperStes |
Comments
Comment #2
shabana.navas CreditAttribution: shabana.navas at Acro Commerce commentedNot 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.
Comment #3
jweirather CreditAttribution: jweirather commentedRegarding the cache clear required on rule edit, there is an open issue/patch for it, here:
https://www.drupal.org/project/rules/issues/2816033
Comment #4
TR CreditAttribution: TR commented@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.