1

I have custom content type with "price" field.

I would like to log the information about when the price has been changed (by administrator). All I need is date and old/new value of that field (for each entity of my custom content type).

But how to monitor such changes? Can I use any hook for it?

  • @Pierre.Vriens Sorry, I eventually used another ready-made module for auditing fields and forgot to give you feedback. But I checked your answer and it works too, so I accepted it :) – PolGraphic Feb 13 '17 at 13:38
0

Step 1 - Detecting changes

You can make this work using the Rules module:

  • Rules Event: Before saving content.
  • Rules Condition (1st): "Entity has field", whereas you should specify these values:
    • "node" (saved content) for the "data selector" of entity.
    • the machine name of your price field.
  • Rules Condition (2nd): Compare the value of the specific field, for both the original value (before editing the field) and the (new) updated value, to verify if they are different. For this you add an additional Rules Condition which is a Data comparison. And the actual data to be compared are:

    • original value of the field, which you should be able to find/select by first using as data selector the node-unchanged:...(unchanged content), followed by selecting the field name of your field from the additional list that is shown after you selected that node-unchanged:...(unchanged content).
    • updated value of the field, which you should be able to find/select by first using as data selector the node:...(saved content), followed by selecting the field name of your field from the additional list that is shown after you selected that node:...(saved content).

Step 2 - Logging changes

By using the Message module, you can create your custom logging of changes detected by the Rules module. For way more details on this, refer to the answer to "What is a good flexible way to send auto system emails to users?".

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.