Help · Chapter 12

Rules

Rules let a form or workflow react to what people do. A rule can show or hide a question, make it required, fill in a score, show a warning, stop a save, open a particular form next, or email someone. You build rules by snapping blocks together, a bit like the children's coding tool Scratch.

This chapter explains the two ways a form can decide what it shows, how to switch between them, the blocks editor, every block, worked examples, daily scheduled rules, and emails.

Classic settings or rules from blocks

Forms

Each form chooses how it decides what shows and what must be answered. Open the form in the form designer and click the Rules tab. At the top it says This form uses: with two choices:

ChoiceHow it works
Classic settingsEach question's Show only when and Required when settings decide what shows and what must be answered.
Rules from blocksYou build rules with blocks on the Rules tab. The Classic settings are replaced by these rules.

New forms start on Classic settings. Classic settings are simpler and cover most needs: "show this question when that button is picked". Rules from blocks can do more: compare numbers, add up scores, show messages, refuse a save, and send emails.

Workflows

Each workflow has its own rules, separate from its forms' rules. Open the workflow and click the Rules tab. It says Rules for this workflow: with Off and On.

  • Off (the start for new workflows): "Rules are off: the workflow runs as its forms and buttons say."
  • On: the blocks editor appears, with the workflow blocks.

Rules you made before are kept when you switch Off, and come back when you switch On again.

Switching a form to rules from blocks

  1. Open the form and click the Rules tab.
  2. Choose Rules from blocks.
  3. kep7 turns the form's Classic settings into blocks automatically, so nothing is lost. (If the form already has blocks from an earlier time, those are used instead.)
  4. Change or add rules in the blocks editor.
  5. Click Save draft, then Publish… when ready.

While blocks are on, a question's or element's settings no longer show Show only when or Must be answered only when. Instead they say to use the Rules tab.

Switching back to Classic settings

  1. On the Rules tab, choose Classic settings.
  2. Each question's Show only when and Required when settings are used again.
  3. The blocks are kept but not used. kep7 says: "This form's blocks are kept, and come back if you choose blocks again."
Important: Switching back to Classic doesn't turn your blocks into Classic settings. Anything the blocks did that Classic settings can't do (such as warnings or emails) stops while the form is on Classic.

Ready-made rules

The Ready-made rules box at the top of the Rules tab builds common rules for you from a short sentence. Choose a rule, fill in its sentence with the dropdowns, and click Add this rule. kep7 adds it to the blocks below ("Added. It's in the blocks below, where you can change it."), so you can change it later like any rule. Adding one to a form on Classic settings switches it to rules from blocks (the Classic settings are turned into blocks first, so nothing is lost); adding one to a workflow switches its rules on. When a question's buttons come from a list, the rule offers that list's answers. A Mark a picture question with kinds of mark offers its kinds (the answer "is" Burn when a Burn is marked), and a Barcode question that looks codes up in a list offers its codes.

On a form:

Ready-made ruleThe sentence
Ask for an explanation when an answer meets a conditionWhen *question* is *answer* (or is less than, more than… a value), show *the question to explain* and make it required. Otherwise hide it.
Calculate a totalSet *the question holding the total* to the total of: *the questions ticked*.
Show a warning when an answer meets a conditionWhen *question* is *answer*, show a warning saying *your words*.
Don't save when an answer meets a conditionWhen saving, if *question* is *answer*, don't save, and say *your words*.
Email someone when an answer meets a conditionWhen saving, if *question* is *answer*, email *who*, with a subject and message.

On a workflow:

Ready-made ruleThe sentence
Open a follow-up form after a particular answerWhen *form* is saved, if *question* is *answer*, open *another form* next.
Email someone if an expected entry is missingEvery *day* at *time*, if nobody has recorded *form* today, email *who*, with a subject and message.
Flag information that has become out of dateWhen it opens, if nobody has recorded *form* in *the period*, show a warning saying *your words*.
Email someone when an answer meets a conditionWhen *form* is saved, if *question* is *answer*, email *who*.

If something in the sentence is missing, it says what, e.g. "Please choose a question."

Important: Emails leave kep7. Don't put health information in them; say where to look instead.

The blocks editor

The editor says: "Drag blocks from the left to build rules. Each rule starts with a when block. Rules save with the form (or workflow) and are checked when you publish."

Parts of the editor

  • Categories down the left side (When, Do or Workflow, Logic, Answers, Maths, Words, Time and people). Click one to see its blocks.
  • The workspace, where you build rules.
  • Zoom controls (+ and −), and a bin for removing blocks.

Building a rule

  1. Click the When category and drag a "when" block onto the workspace. Every rule starts with one, and a "when" block can only go at the top of a rule.
  2. Click another category and drag a block into the "do" gap of the "when" block. The block snaps into place.
  3. Keep adding blocks. Blocks with a gap on their side take a value (such as a number or an answer); blocks with notches top and bottom are actions that stack in order.
  4. Use the drop-downs on each block to pick the question, form or option.
  5. Click Save draft on the form or workflow. Rules save with it.

Zooming and tidying

  • Use the + and − controls, or hold Ctrl and turn the mouse wheel, to zoom. kep7 remembers the size in this browser.
  • Drag a block to the bin to remove it. Dragging a block also drags everything attached under it.
Tip: Build one rule at a time and try it in Preview before adding the next.

Form blocks

These blocks are available on a form's Rules tab.

When

BlockWhen it runs
when answers changeWhenever an answer changes, and again when the form is saved
when it opensWhen someone opens the form. Use it for starting answers and messages.
when the form is savedWhen Save is pressed, before the entry is kept

Do

BlockWhat it does
show [question or element]Shows it
hide [question or element]Hides it. A hidden question's answer isn't kept.
make [question] requiredThe question must be answered
make [question] optionalThe question can be left empty
set [question] to …Sets a question's answer, for example a score
show [a note / a warning / good news] saying …Shows a message at the top of the form
don't save, and say …Stops the save and says why (use it in a "when the form is saved" rule)
email [to] subject … message …Sends an email (see Emails from rules)

Logic

  • if … do: does something only when a condition is true.
  • if … do … else: does one thing when true and another when not.
  • A ready-made comparison number from [question] < 5. Change the question, the sign and the number.
  • An empty comparison, with =, ≠, <, ≤, > and ≥.
  • and / or, to join conditions.
  • not, to turn a condition around.
  • true / false.

Answers

BlockWhat it gives
answer to [question] < 5True when the answer compares as chosen. < and > use the answer as a number; = and ≠ use it as given.
answer to [question]The answer, as given
number from [question]The answer as a number: a button's value from its list, or several added up
[question] is [answer]True when this button is the answer (or one of those picked)
[question] is answeredTrue when it has an answer
how many picked in [question]How many buttons are picked
for each answer picked in [question] doRepeats for each button picked (up to 100 times)
the answer pickedInside "for each answer picked": that answer
entries of this form [period] by [me / anyone]How many entries the person can see, today, this week, in the last 7 days or in the last 30 days
fill-in [word]A fill-in value the project or workflow gives the form

Maths

  • A number.
  • Add, take away, times, divide, and power.
  • Round (also round up and round down).
  • smaller of / bigger of / average of … and ….

Words

  • A piece of text.
  • Join pieces of text together.
  • The length of some text.
  • Whether text is empty.
  • … contains … (true when the words, or the answers picked, include these).

Time and people

  • the [hour (0-23) / minute / day of the week (Mon 1 - Sun 7) / day of the month / month / year]: now, where the project is.
  • today is [a weekday / a weekend day / Monday … Sunday].
  • the person's [name / email]: who is filling it in. Blank on anonymous links.

Workflow blocks

Workflow rules look across all the workflow's forms. Questions in drop-downs are named "Form: question". Workflow rules can't show, hide or require questions; those are form rules.

When

BlockWhen it runs
when it opensWhen someone opens the workflow
when [any form / a form] is savedWhen a form in this workflow is saved
every [day / weekday / weekend day / Monday …] at [17:00]Once a day at that time (see Scheduled daily rules)

Workflow

BlockWhat it does
open [form] nextAfter saving, opens this form
offer a button for [form] saying …Shows a button that opens this form (up to 6)
end the workflowAfter saving, goes back to the project's page
show [a note / a warning / good news] saying …Shows a message
don't save, and say …Stops the save and says why
email [to] subject … message …Sends an email

The Logic, Answers, Maths, Words, and Time and people categories are the same as for forms. In a workflow, entries of lets you pick which form to count.

Worked examples

Example 1: low sleep needs an explanation

Goal: if the answer to "Sleep" is less than 5, show and require "What happened overnight?" and show a warning. Otherwise keep that question hidden.

Questions show unless a rule hides them, so the rule needs to hide the question when sleep is 5 or more.

  1. On the form's Rules tab, choose Rules from blocks.
  2. From When, drag when answers change onto the workspace.
  3. From Logic, drag if … do … else into its "do" gap.
  4. From Answers, drag answer to [question] < 5 into the "if" gap. Pick "Sleep". Leave the sign as < and the number as 5.
  5. From Do, drag show into the "do" gap of the "if" block and pick "What happened overnight?".
  6. Under it, drag make [question] required and pick "What happened overnight?".
  7. Under that, drag show [a warning] saying and type "Less than 5 hours' sleep. Please say what happened."
  8. From Do, drag hide into the "else" gap and pick "What happened overnight?".
  9. Click Preview, move the Sleep answer below 5, and check the question appears, is required and the warning shows. Move it back up and check the question disappears.
  10. Save the draft and publish.

The finished rule reads:

  • when answers change
    • if answer to Sleep < 5
    • do: show What happened overnight?; make What happened overnight? required; show a warning saying "Less than 5 hours' sleep. Please say what happened."
    • else: hide What happened overnight?
Tip: When kep7 turns Classic settings into blocks, a "Show only when" setting becomes a rule of the form "if not (these answers) hide the question", and a "Required when" setting becomes "if (these answers) make the question required". Looking at the converted blocks is a good way to learn.

Example 2: a total score

Goal: add up three slider answers into a "Total" question.

  1. Add a Number question called "Total" to the form.
  2. On the Rules tab, drag when answers change onto the workspace.
  3. Drag set [Total] to into it.
  4. From Maths, put an add block into the "to" gap, and another add block inside it so there are three spaces.
  5. Fill each space with number from and pick each slider.

Example 3: stop a save that doesn't make sense

  1. Drag when the form is saved onto the workspace.
  2. Add if … do, with a condition such as answer to "Drinks today" > 30.
  3. In the "do" gap, add don't save, and say and type "That's more drinks than expected. Please check the number."

Example 4: open the right form next (workflow)

  1. On the workflow's Rules tab, choose On.
  2. Drag when [a form] is saved and pick "Morning check".
  3. Add if … do with "Morning check: Feeling unwell" is "Yes".
  4. In the "do" gap, add open "Symptoms" next.

Scheduled daily rules

A workflow rule that starts with every [day] at [time] runs once a day at that time, where the project is (using the project's time zone). It runs separately for each project that uses the workflow.

  • Choose day, weekday, weekend day or a single day of the week.
  • Type the time in 24-hour form, such as 17:00 or 08:30.
  • If kep7 was restarting at the time, a missed rule still runs later that day.

A typical use is a daily check, such as: every day at 20:00, if entries of "Evening log" today by anyone = 0, email the project's owner "The evening log hasn't been filled in today."

Emails from rules

The email block sends an email. It sends only when a form is saved or when a scheduled rule runs, not while someone is still filling in a form.

Who it goes to

ChoiceWho gets it
the project's ownerThe owner
the project's correctorsEvery Corrector in the project
everyone in the projectAll members
the person savingWhoever saved the form
the group [name]Everyone in one of your people groups

What it can say

Type the subject and message in your own words. Text blocks and joins are fine, as are things like the person's name or the time.

Important: An email can't include answers or fill-ins. kep7 keeps health information out of email. If an email block uses an answer or fill-in block, publishing is refused with: "An email can't include answers or fill-ins: kep7 keeps health information out of email. Write what happened in words; people open kep7 to see the answers."

For example, write "Sleep was low last night. Open kep7 to see the details." rather than trying to put the number in.

Email limits

  • One rule run sends at most 3 emails.
  • A project sends at most 50 rule emails a day.

Limits and checks

LimitAmount
Rules per form or workflow60
Emails per rule run3
Rule emails per project per day50
Messages shown at once10
Times "for each" repeats100
Buttons offered by "offer a button"6

When you publish, kep7 checks the rules. If a rule names a question or form that is no longer there, it loads as "(removed) …" so you can see it. Publishing is refused until you pick another question or form, or remove that block. Other problems, such as an email block with nobody to send to, or a "when" block placed inside another rule, are listed in the "Can't publish yet:" box.

An unhandled error has occurred. Reload 🗙

Rejoining the server...

Rejoin failed... trying again in seconds.

Failed to rejoin.
Please retry or reload the page.

The session has been paused by the server.

Failed to resume the session.
Please retry or reload the page.