To write RuleZ, we recommend that you use the following method:

  1. State what you're trying to do in simple English.
  2. Add the necessary references (question IDs) from your question list.
  3. Turn it into RuleZ!

Using this method will help you to avoid mistakes and get the RuleZ you want more quickly.

Rulez example 1: checking answers and displaying an error message

RuleZ can save your reviewers a lot of time if you use it to catch shopper input errors.  Here's an example of a classic SASSIE input error:

In this case, it seems likely that the shopper has simply failed to select PM for the time-out, but to make sure, the reviewer will have to send the shop back for the shopper to revise.

Step 1: State what you're trying to do in simple English

The way that we would like to prevent this problem, stated in simple English, is:

  1. Check if the start time is later than the end time.
  2. If it is, present the shopper with an error message saying, "ERROR: the start time cannot be later than the end time."

RuleZ can do all of these things, and many more that are described in full on the Reference page.  For now, here's a quick breakdown of the most commonly used RuleZ functions.  First, RuleZ can check and compare the answers to questions:

  • Check if a question was answered ("If the display question was answered…")
  • Check if the answer to a question has a certain value ("If the answer to the display question was 'Standalone Display'…") or is greater or less than a certain value ("If the answer to the 'time to wait in line' question is greater than five minutes…'")
  • Compare the answers to two questions to see if they are the same, or if one is greater than or less than the other (for numeric values) ("If the answer to the 'cleanliness of the bathroom' question is less than the 'cleanliness of the dining area' question…")

Then, based on the results of the check and comparison, RuleZ can change what the shopper or the reviewer sees:

  • Display an error message ("The end time cannot be before the start time.")
  • Hide or show part of the form (display return questions only if the shopper indicated that they have performed the optional return part of the shop)

Basically, RuleZ can do everything that we've specified in our simple English statement of what we'd like to do.

A helpful way to organize your requirements and make sure there are no conflicting RuleZ is to make a list of all the conditions that should happen. You will end up with a series of combinations, each one a group of conditions and a single effect. Make each of hose combos a single Rule, and then you will have no overlaps, no duplicates, and everything will be able to run conflict-free.

Step 2: Add the necessary references (question IDs) from your question list

Next, we want to add the question IDs from the sample survey as shown below:

…and, while we're adding the question IDs, let's also change our wording a bit.  Our RuleZ worksheet now looks like this:

  1. Check if the value of QID 11 is greater than the value of QID 21.
  2. If it is, present the shopper with an error message saying, "ERROR: the start time cannot be later than the end time."

Step 3: Turn it into Rulez!

Now comes the fun part – writing the actual RuleZ!  There are many different operations that can be done with Rulez (see the Reference page), but this example uses three operations as follows:

The first operation is IfQ. This checks the answer to a question.  If we want to check the answer to question 11, we would type:


Capitalization is VERY important in RuleZ!  Remember, it's ifQ, just like that – not ifq or IFQ.

The second operation is .greaterThan.  This compares two values to see if the first one is greater than the second one.  If we wanted to check if the answer to question 11 was greater than question 21, we would type:



The third operation is .setError.  This says what to do if the answer to the previous operations (the comparison of the two values to see if the first is greater than the second) is "yes" or "true".  To display the error message from our example, our Rule now look like this:



.setError("ERROR: the start time cannot be later than the end time.");

Did you notice something different about that last operation?  It ended in a semicolon.  This is very important!  When you get to the end of your Rule – basically, the end of your "check this and then do that" – you need to add a semicolon to tell RuleZ that this is the end of this Rule.

 Another thing you may notice is the parentheses.  Most operations are followed by parentheses that contain the "stuff" that the operation will be performed on – and just like in high school algebra, the parentheses need to match.  If you have a left parenthesis, you need a right parenthesis to match it.

Our Rule is almost ready to go.  We just want to add one more thing:  comments.  Comments are notes to yourself (or to anyone else who reads your RuleZ).  You know what your Rule is all about right now – but will you remember if you have to come back and edit it in a couple of weeks?  Will you still know what question ID 11 and question ID 21 are?  Save yourself the trouble now by adding some comments that describe what your Rulez are supposed to do.

Comments are written by starting with two back slashes (//).  Anything that is written after two double slashes is ignored.  You can add comments on separate lines, or to the right of your RuleZ.

Adding some comments, we now have:

ifQ(11)                  // if start time
.greaterThan(Q(21))     // is later than end time
.setError("ERROR: the start time cannot be later than the end time."); // then write an error message and let the shopper know

Now all you have to do is type your code into the RuleZ Editor:

Tip: as you work, save your rules in a text file to make sure your work is not lost.  Do NOT use Microsoft Word – it inserts special characters that will make your RuleZ unreadable to SASSIE.  Use textedit (for Mac) or Notepad (for Windows) instead.