Posted by raslee on January 24, 2012 at 12:55pm
I have managed to get my rule to react on info from a date field placed in every user profile.
The thing is, if the date put in the date field is already passed, the rule will fire right away - even if the date is years ago.
In this case a user fills out the date of his sons birth. Let’s say the date is 1. January and the offset is 5 days and he fills out the date field today, the rule will react right away, because the date has passed, and the user will get a mail there no longer is of any importance to him.
So how do I avoid my rule reacting on dates that has already passed?
Does that make any sense?
Hope someone can give me a hint.
Thanks a lot!
/raslee
Comments
Some kind of condition
I think the best way to do this is to add another condition in the component that is scheduled. (You are using Rules Scheduler, right?)
Have an extra condition check that the set date is not older than, say, five days before executing any actions.
Another approach would be to add the condition on the rule that schedules the task, and only schedule it if the date is in a given range.
I believe that the standard way Rules Scheduler evaluate tasks is to see which tasks are in "the past" and execute these. Usually these are only a few minutes old, but in your case it is not so.
Good luck,
//Johan Falk
**
Check out NodeOne's Drupal Learning Library! 250+ screencasts and exercises, for Drupal introduction, advanced configuration, and coding. Creative Commons license!
Thanks - what kind of condition?
Hey Johan,
Thank you for your answer.
It would be great if I could add a condition to the component, but what would that condition do? Data comparison? With at value that is equal to the date in the date field? And maby added an offset? Am I totally on the wrong path here...
/raslee
Eh, dunno
I don't know if there's a fitting condition for this, but I would try using the "data comparison" as you suggest. Sorry. :-/
What kind of component plugin
Thanks again.
Would it make any different, according to the executing of old actions, if the component plugin is a condition, action or a rule?
/raslee
Don't think so
I don't think so. The only difference is what can be put into the component – not how they are scheduled for evalutation.