0

I'm using Drupal 7, with Rules and Rules Scheduler.

I have a content type "Tutorial Class", with fields as below:

  • Class Date and Time
  • Feedback requested (Radio button: Yes/No, default is no)

I would like to create a Rule, so that whenever the cron runs, it will check on all "Tutorial Class" content type.

If current time is larger than "Class Date and Time" field, and "Feedback requested" is no, an email will be triggered and "Feedback requested" will be changed to Yes.

Currently I know how to trigger email after "Tutorial Class" is created, but I can't get the above Rule done.

Any idea of how to set this rule?

0

Hi You can add a filed in your content type like date_content_type . a)chose filed type =date in content type(admin/structure/types/manage/content_type/fields)

b)add a condition in Rule set c) select condition= data comparison d) click on continue button e) select data selector set your custom date type field f)then add your time() value and save it . now your date condition rule set will be execute i hope it will help you Thanks

0

This is exactly what the Rules Scheduler is for.

First, whenever you want to create a Reaction Rule, you have to answer the question WHEN do you want an action to happen. You are implying that you want to periodically (via cron) loop over all your nodes and do a date comparison. That's not a good idea, is super inefficient, and that's not the sort of task Rules was designed for. Although, it IS possible to do this in Rules if you really really want to.

Instead, the way you should be thinking about this is, WHEN your node is saved or updated, THEN schedule an e-mail to be sent on the class date. See, you have a WHEN which represents the event, and you have a THEN which represents the action to take. You can also add conditions (IF something is true ...) to this Rule if necessary. Thus, no endless looping and comparing dates is needed - the Rule executes only once and only when needed.

So in this case, the Rule can be described as:

WHEN a "Tutorial Class" is created or updated THEN schedule a Rules Component to be executed on the day of the "Class Date and Time" field.

The Rules Component that you schedule would contain a "Send a mail" action and an action to set the checkbox value to "Yes".

This procedure also works when the "Tutorial Class" is updated with a new date - the scheduling action will overwrite the previously scheduled component and update it with the new date, so the mail will be sent only once, and on the correct date.

Your Answer

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

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