How can I insert data in database using Rules?

I created entity type Job and added some fields. I want to insert values inside those fields when the flag button is clicked. I tried "set a data value" but I think it will work if I already have an existing field and value.

I also tried to use "add variable" in my Rules Action and set value on it. My question is how can I validate if it's working?

PS: I tried to look the data inside my database but I can't see it.

  • This question appears to be off-topic, as per the help page here (drupal.stackexchange.com/help/on-topic), which clearly indicates that requests for tutorials and other online resources is not appropriate here
    – Geoff
    Jul 25, 2014 at 19:55
  • but to answer you question, sort of, yes it is possible. If you post what you have tried, how it didn't work, and what the expected results are, you may get a better answer.
    – Geoff
    Jul 25, 2014 at 19:57
  • @Geoff : I think your first comment no longer applies (revision 2 of the question resolved your valid remark to the original version). Aug 24, 2016 at 14:47

1 Answer 1


Before you will be able to create a Rules Action like "Set a data value" for your field, you have to make sure to add a Rules condition Entity has field (related to the field for which you want to set a value). And make sure to add that Entity has field condition BEFORE other Rules Conditions in which you might want to refer to this field (if you have any such conditions in your rule).

That's also what is mentioned in the Rules UI, e.g. when you're adding a "data comparison" condition: somewhere it says "The data selector helps you drill down into the data available to Rules. To make entity fields appear in the data selector, you may have to use the condition 'entity has field' (or 'content is of type')".

For a video tutorial that illustrates the importance of this Entity has field condition, refer to Data types and data selection, especially what is shown between about 13:30 and 17:30 in it.

And to validate if your rule is working, just add a "Set a message" (within System) as your very first Rules Action, to display the actual value (using an appropriate token for your field), after your executed your rule (and re-execute it). If that doesn't work (or help), use Rules debugging, as detailed in "How to debug a rule that doesn't want to fire?".

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.