1

I have a content type which has an end date field, once the current date is past this end date then I need to change a boolean field to 0 on that particular node.

I am really struggling to get anything close to working (using the Rules module), I am getting values such as this in my Data selectors:

  • node:field-category:0
  • node:field-category:1
  • node:field-category:2
  • node:field-category:3

I don't know why these delta values are there or how to get rid of them, every video tutorial I watch the persons data selection is working perfectly.

I understand I need to drill down by adding a Rules Condition to check for a particular field on the node type in question. But, like I said, I am just getting these delta values.

Now coming to the loop and I am unable to get the value from the end date for the very reason that it is not there.

Even when I have gotten close to having the loop working, when I look for the boolean field which needs to be altered if the current date > end date, this is also showing me several values with numbers after them.

What am I doing wrong?

  • The delta values show up when the field has more than one or unlimited values allowed in its settings. – Niall Murphy Dec 10 '16 at 1:38
0

From the "...adding a condition to check for a particular field on the node type in question..." in your question, I bet you are aware about the importance of adding a Rules condition Entity has field (related to your field you're looking for). If not have a look at 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')".

However, even though nowhere in your question you indicate which Rules Event you're using, I bet you're using the wrong one. And the "Rules once per day" in your title is probably a good indication of what you really try to use as a kind of Rules Event (which is not really an event).

Nevertheless, I think you're just using the wrong approach (sorry). What I would do in your scenario, is a variation of my answer to "Rule to store user's last post date and scheduled rule based 30 day reminder". Some more details about how to adapt that answer to fit your case here:

  • Create a variation of the Rules Component (in Step 2) to change that boolean field for "a" node (which at least requires the node id as a parameter). Use the "execute" link in front of the Rules Component to QA-test your component (with a single node id, etc).
  • Create a variation of the Rule (in Step 3) like so:

    • Use a Rules Event like "when such node gets created or updated" (something that fits your case).
    • In the Rules Condition of that rule, for sure you'll be able to use the "Entity has field" condition (for your date field).
    • In the Rules Action, you "schedule" the execution of the Rules Component mentioned above. For this you need to enable the Rules Scheduler, and that should do the trick.

Last but not least, be patient ... and wait until the specified date arrives, then wait for your next cron job to run (if you don't run that, nothing will actually get executed, be aware!). And then: voilà.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy