3

I'm trying to set up a rule (using the Rules module) with AND and OR conditions. I have a content type with a field A (date) and field B (time slot).

The rule needs to check if field A is either e.g. a Monday or a Wednesday AND if the time slot in field B is either 16:00 or 17:00 or 18:00 or 19:00 (on a Monday) OR 13:00 or 14:00 or 15:00 or 16:00 (on a Wednesday).

If it meets those criteria it has to perform an action.

I've set up my rule as shown in the screenshot, but alas whatever combination or indentation I use, it won't work ...

Who can shed some light on this? Much appreciated.

enter image description here

3
  • I think you only need one "OR" and 8 "AND"s: (Monday AND 16:00) OR (Monday AND 17:00) OR ... OR (Wednesday AND 15:00) OR (Wednesday AND 16:00). Or have I misunderstood your situation? – Jeroen Jul 6 '16 at 20:08
  • Hey b@Jeroen , I think your comment might also work, though you'd be testing "Is it Monday" 4 times (I think), What your comment doesn't say is how the "indents" should like (as you must know: crucial to get it to work). Why not post an answer similar to mine (feel free to copy/past my layout I used and adapt it to what you suggested). If you do, and assuming both answers are correct, Colin is going to have a hard time to select which one to "accept", no? – Pierre.Vriens Jul 6 '16 at 21:11
  • Merci for your (late) accept of my answer ... So what's next, no other Rules-related questions anymore? – Pierre.Vriens Apr 7 '17 at 13:14
1

You need 2 extra ANDs, right below the highest level (1st) OR.

And EACH of the 2 ORs you already have, and the Data comparison that preceeds those ORs, you need to move them below the extra AND. So that in the end it looks like so:

  • OR
    • AND
      • Data Comparison (A=Maandag)
      • OR
        • Text Comparison (B=16:00)
        • Text Comparison (B=17:00)
        • Text Comparison (B=18:00)
        • Text Comparison (B=19:00)
    • AND
      • Data Comparison (A=Woensdag)
      • OR
        • Text Comparison (B=13:00)
        • Text Comparison (B=14:00)
        • Text Comparison (B=15:00)
        • Text Comparison (B=16:00)

Here is how "I" would translate the above logic:

  • We accept a date that is either on Monday (line 2 to 8) OR (line 1) Wednesday (line 9 to 15).
  • If you want a date that is a Monday (= line 3), we insist (via the AND in line 2) that you pick a timeslot that fits for us on Monday.
  • To pick a timeslot for Monday, you have a choice (OR in line 4) of 4 options (ie those in line 5, 6, 7 or 8).
  • Similar Rules, oeps rules, apply for Wednesday, as expressed in line 9 to 15.

If after these changes your Rules Action(s) still don't get executed (because something else is wrong in any of these Rules Conditions, and/or you're not using an appropriate Rules Event), then move on to Rules debugging, as explained in "How can I display the value of a variable inside a condition?".

PS: just to make sure your "Text Comparison" condition behaves as you expect/hope it to do, create a temporary clone of your rule with only 1 Rules Condition (= 1 such text comparison), with same Rules Event and same Rules Action. That way you can either narrow down your problem, or exclude that as a possible reason why it still doesn't work.

1
  • Thanks, seems logic now when I see it. But ... it doesn't seem to work. When I choose monday, no matter what time, it still evaluates as false. "The condition data_is evaluated to FALSE " – Colin A Jul 7 '16 at 11:02

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.