Hey everyone. I'm trying to set up a rule that is scheduled to fire some time in the future. I'm using drupal 7, and I'm pretty new to that version of Drupal. I'm pretty familiar with drupal 6, but I've never quite done anything like this before.
I'll try to explain what I'd like to happen a bit more clearly. I created a new content type called future item. That future item contains a date field and I would like to send out a reminder email when that date passes. I'm a bit confused about how to set up the component necessary to set up the rules scheduler. I see there are tutorials for scheduling rules for the drupal 6 version of rules, but I don't see much documentation or tutorials on it for drupal 7. Perhaps I'm not looking in the correct place?
Anyone have any insight they can share with me? Am I not going about this correctly? I'm trying to set up the rule, and then set up the component to access the date field set up in the custom content type, but I'm having some trouble setting that up.
Any help?
Thanks much,
iLan
Comments
Not much help, sorry
I have not yet used Rules Scheduler for Drupal 7, so I can't give much help.
There are still some things in Rules 2 that needs ironing out, so if you experience problems even if you think you're doing the right things it is possible that you have found a bug. If so, the maintainers would be happy for a report. :-)
You don't describe how you go about setting up your scheduling, so I don't know if it is Rules or the configuration that is the problem.
What you need is (1) a reaction rule that acts on creation (or possibly update) of "future event" nodes, and (2) a rule/rule set that should be called on the future time. The reaction rule should, when called, schedule the rule set to execute at the time set in the field of the future event node.
I hope this might make things clearer. Good luck!
//Johan Falk, NodeOne, Sweden
Want to learn more Rules? Check out my latest screen cast series!
D6 example that may help
Written for Workflow context but general approach will be similar: scheduling a future event.
Thanks!
You guys are great! RdeBoer, that link especially was a great help to me. What I was having a hard time understanding, was how the component set was supposed to be set up. I was setting it up as an action, where it should have been set up as a rule or rule set.
What I ended up doing was to create a rule that fires when creating new content. That rule does nothing except check to see if the content type is "future event" and if so, "schedule a component evaluation" action. I created a component which evaluates the node-field-delivey-date and if that date is "less than" now, it fires an action which "sends an email".
I was able to successfully send two emails which were sent at their specified times in the future! Awesome!
Thanks very much for your suggestions in this. They were very helpful to me to help me understand what I was doing incorrectly. I just didn't completely understand how/when each rule/action was firing.
Thanks again,
iLan
Similar use case
I'm trying to implement a similar rule only in my case I want to expire the node after the set date. I've followed the steps you have outlined in your final post @thepuzzlemaster but I must be missing something. In the component I'm doing a data comparison and selecting node as a component variable. However my date field is not available in the data selector drop down box. I can see node:body: etc. but how do I compare a date with my expire field?
Thanks,
Mike
Remember to set content type (with required field) as condition
I don't know if you managed to solve your problem, Mike, but in case anyone else stumbles across this thread I thought I might share my experiences.
To begin with my date field wasn't available to me either when setting up the scheduled rule. I had to set a condition on content type article (which contains my date field) before I could choose the date field. It seems (logically) that Rules only exposes fields for the content types you are working with so if you haven't set up a condition for a specific content type you can only access generic fields shared by all content types. I don't know if that was the cause of your problem too.
I managed to set up a basic scheduled workflow rule that triggers on a dropdown text field where the editor can select different workflow states (draft, ready for editing, ready for publishing, online). My content type also has a date field, and when the editor chooses "ready for publishing" and the datetime is in the future a schedule task is set up to publish the article on that datetime. I created a second rule that publishes the article immediately if the datetime is in the past. Currently looking into if I can do both in the same rule but I have only played around a little with Rules on Drupal 6 so I am still very new to the module on Drupal 7.
Johan Falk's Rules screencast is great (http://nodeone.se/blogg/learn-rules-with-nodeone-part-1-overview) but a lot of things including the UI has changed in Rules 2 for Drupal 7 so there definitely is a lack of documentation. Hopefully I can help when I understand the module better.
Would be happy to hear any experiences with building Rules based workflows or links to updated documentation for Rules 2.
Cheers,
Casper
I'm also having a problem
I'm also having a problem with scheduling a future event with Rules, but of a slightly different nature. I finally managed to get the scheduled component to fire at the future time, and got it to update a field, but instead of updating the old node, it created a new node and update that node.
Is there some way or need to reference a specific node ID in component rules when doing a update value of a data field action?
What actions do you use?
This sounds very strange. If Rules creates a new node, I think the "create a new entity" action is required. Are you using that?
To have Rules Scheduler update an existing node, that node must (almost) be a parameter for the component that is being scheduled. The node will then be specified when the component is scheduled, and a reference to the node stored until the time of the scheduled evaluation.
Working with components might be a bit tricky at first, but is awesome when you get used to it. Check out episode 6 (and maybe more) in this screencast series if you feel uncertain about components: http://dev.nodeone.se/node/984
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 Johan, your work at
Thanks Johan, your work at NodeOne has been a great help, it's a fantastic resource!
I think I might have solved the problem.
Yes, I am using the create new entity action. What seems to be working better is separating the actions into separate rules. Before, I had the "create new entity action" and "schedule rule component" in the same rule set.
So now I have a rule which creates a new entity. Then I have another rule which activates on the event "new entity has been saved", and this second rule is the one that schedules the activation of the component which does the future update of originally created entity. Seems to be working for now.
For some reason, having the rules scheduler activate in the same rule set which created the entity, caused it to create another instance of the node entity when the scheduled task eventually ran. Not sure why, but separating them appears to solve it.
Hej David, Could you tell me
Hej David,
Could you tell me a little bit about your settings in order to get Rules to fire on a date.
I'm having som trouble with getting Rules to read the date from the date_field - it seems to only want to fire on the date of filling out the date_field.
Thanks a lot.
raslee
I second the request
Hi Davidcsonka,
I also would like to know what user raslee is asking . What are you writing in the field
"Scheduled evaluation date"
Rules seems to take only the current date. I tried the below php code in the evaluation box but it did not work
$timestamp = time();
$formatsecond = date("s",$timestamp);
$formatmintue = date("i",$timestamp);
$formathour = date("H",$timestamp);
$formatmonth = date("m",$timestamp);
$formatday = date("d",$timestamp);
$formatday=$formatday+1;
$formatyear = date("Y",$timestamp);
$daystart = mktime(0,0,0,
$formatmonth,$formatday,$formatyear);
return $daystart;
Than you,
Vishal
You need to add an offset
Below "Scheduled Evaluation date" there should be a field for "Add Offset", that is where you put in how days or hours you want to elapse past whatever value you put in the "Scheduled Evaluation date" field.
So,
If for "Scheduled Evaluation date" you put "site:current-date", and for "Add Offset" you put "1 day", your component will get scheduled to execute in exactly 1 day from when the triggering rule executes.
Unable to add offset
In the Add Offset field, no textbox is shown below Add Offset to add. Please help. Which type of issue is this. Or what i am doing wrong.