1

I am using rules to set a data value of a field on a node. Works great!

BUT, when the rule is triggered, the node's 'updated' timestamp is changed. In my particular application, I do NOT want this to happen. I totally understand why this behavior might be desired by some (most), but in my case I don't.

Is there any way to prevent the 'updated' timestamp from being updated when rules is used to set/change the value of a field on that node?

Here are the nitty gritty details of my application: I have two node types: Parent & Child The child node includes an entity reference field to relate it to its parent node. When a child node is created or updated, I use rules to change a field value of it's parent node. I got that all to work great, but, when the rule is triggered, the parent node's 'updated' timestamp is changed to the current time, which I do not want.

I also posted this question to the Rules issue queue on d.o: https://www.drupal.org/node/2796899

1

If it is not necessary for you to use rules, you can also try to invoke the hooks node_update and node_insert. There you can load the parent, change the fields value and save it with the field_attach_update function.

You can find an interesting article about this at https://www.urbaninsight.com/2011/10/24/saving-nodes-fields-without-saving-node-itself

  • Thanks, this looks promising. But, the reason I was using Rules is because I am not a coder and don't know a lot about how to do what you suggested. Someone else suggested using the message module to accomplish my goal. But I have not figured out how that would work yet. – Arlin Sandbulte Sep 13 '16 at 21:35
  • Rules is going to use the core APIs for updating fields and nodes. That means in the end it will call entity_save (or node_save). If you want to bypass this behavior, this answer is pretty spot on. – Kevin Sep 13 '16 at 21:45
  • Without coding you can try to add a custom date field where you save the time when the node was last time edited. Then you can create a new rule, which updates this field value every time you need. – Chris4783 Sep 14 '16 at 6:31

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.