Search code examples
drupalalertdrupal-rules

How to set up a rule whitch will be executed every day?


I am trying to set up a rule that will send me a mail when a node will expire the next day. and of corse the rule must be executed every day in order to work.

So I have a content type 'event' with the field 'end date' When the current date is one day earlier to the field data 'end date' I want to receive a mail : 'the event [node:url] will end tomorrow'

Thanks for your help and excuse my english.


Solution

  • Best way to do this without using Cron is to schedule the email to be sent when you save that content type.

    So, basically, you add a new rule triggered when content of that content type is saved which schedules the email to be sent the day before the "end date".

    UPDATE (adding overall steps on how to achieve this):

    1. Go to Configuration > Workflow > Rules > Components and add a new component of Action Set type; configure a variable on that action set to be the Event content type you want so you get the full details about the event there so you can embed the URL on the email and all that
    2. Go to Configuration > Workflow > Rules and add a new rule
    3. Choose the trigger to be "After saving new content" and then add a condition to check for the right content type ("Content is of type")
    4. Add an action to "Schedule component evaluation", pick the Component you created and configure it to run on the event date - 1 day (switch to data selection, pick the field with the end date and add a negative offset of -1 day
    5. Configure the Event you want to pass as a parameter so the Component gets the right event and can use it on the email

    That's it, you should be all set.