# Set a campaign's rules and availability

## Purpose
Decide what each assessment in a campaign looks like before anything happens, write the
rules that change it, and publish the result to everyone on the roster.

## Who this is for
Account administrators and campaign managers.

## Before you start
- A campaign with at least one assessment in it. See
  [Publish and preview an assessment](/operate/tenant-admin/publish-and-preview-an-assessment).
- Permission to change campaigns. Reading the rules needs the campaign view permission;
  saving or publishing needs the campaign modify permission.

## Where it is

Open the campaign and choose the **Rules** tab. It shows one row per assessment in the
campaign, and a form at the bottom for adding a rule.

Two badges at the top say where the campaign stands: **Draft vN** is the version you are
editing, and **Published vN** is what participants are currently being shown. If the two
differ you also see **Unpublished changes**: your edits are saved, but nobody is seeing
them yet. A campaign that has never been published says **Never published**.

## Put an assessment into the structure

A campaign that has never had rules starts with an empty structure, so every row reads
**Not in the structure**. Choose **Add to the structure** on a row and the assessment
joins it, keeping the default availability its own settings already carry, so adding a
campaign that has been running for months changes nothing about who has to do what.

Only assessments in the structure can carry rules or be named by one.

## Set what people see by default

**Default availability** on each row is what a participant is shown before any rule
fires:

- **Mandatory**: it counts towards being finished.
- **Optional**: offered, never chased.
- **Hidden**: shown only when a rule says so.

### Assessments open only to people with a label

An assessment can be open only to people who carry a particular label on their roster
row, for example the Federal Procuring Bodies set, open only to people labelled
`institution:pspc`. Its row then says **Open only to people labelled** followed by the
label. Everybody else is not offered it at all, whatever their answers and whatever the
rules say; for the people who carry the label, the default availability and the rules
apply as usual.

The gate is set through the campaign's structure (the graph API, or the Pilot build
kit); the Rules tab and the builder show it. To let somebody open such an assessment,
add the label to their row on the roster: their availability is recalculated as the
label is saved. Removing the label takes the assessment away again. Their completion
panel on the roster says which label opens it.

Each change is saved as you make it. The row also shows who answers the assessment
(each participant, one per organisation, or one per group) and says whether that came
from the campaign's structure or from the assessment's own settings. Change who answers
in the assessment itself, not here.

## Add a rule

A rule reads: *when this answer in the source assessment meets a condition, the target
assessment changes.* The form builds the underlying rule for you; ordinary rules do not
require expression syntax.

1. Choose the **source assessment**: the one whose answers are read.
2. Search the source's pinned questionnaire and choose a **question or result**. The list
   shows each item's title, stored name and type, grouped by its page or panel. Matrix
   rows and multiple-text items appear as their own choices.
3. Choose an **operator** and, where needed, an **answer**. Choice questions show the
   questionnaire's answer labels while saving their stable values; number and rating
   questions use numeric comparisons.
4. To test more than one answer, choose **Add condition**, then decide whether **all**
   conditions (AND) or **any** condition (OR) must match.
5. Choose what happens to the target: *becomes mandatory*, *becomes optional* or
   *becomes hidden*.
6. Choose the **target assessment**: the one that changes.
7. Choose **Add rule**.

The source must have a pinned questionnaire. If it does not, the form says so rather than
showing an empty question list. Activate the assessment to pin its questionnaire before
building the rule.

Each rule appears under the assessment it changes as a sentence using the assessment,
question and answer labels, with **Edit condition** and **Remove** controls. Re-opening a
guided rule restores its conditions. Use **Custom expression** only for an existing or
specialist SurveyJS expression that the guided editor cannot represent; the platform
keeps such expressions unchanged and shows their stored text with the rule.

Rules are evaluated when the source is finalised, over the answers of the participant's
unit. Until then the target shows as locked rather than absent.

## What the platform refuses, and where it says so

Every change is checked as it is saved, and a refused change is **not stored**: it stays
on screen with the reason beside the thing that caused it, so you can fix it or remove
it. A banner at the top says that nothing was saved. The reasons are the platform's own,
each with a code you can quote in a support request. The common ones:

- `AVAILABILITY_CYCLE`: the rules chase each other in a loop, so no assessment could
  ever be resolved. Shown against every rule on the loop; break one of them.
- `CONDITION_NAME_UNRESOLVED`: the expression names a question the source assessment's
  questionnaire does not have. Names are checked against the version the campaign is
  pinned to, not against whatever the template says today.
- `CONDITION_UNPARSEABLE`: the expression is not valid.
- `UNIT_CONTAINMENT`: the source is answered by a narrower group than the target, so
  the answer it reads cannot speak for everyone the rule would change. An
  organisation-level assessment may gate a participant-level one; the reverse is refused.
- `AUDIENCE_LABELS_EMPTY`: an assessment is set to open only to people with a label, but
  no label is named, so nobody could open it.
- `AUDIENCE_ALWAYS_HIDDEN` (a warning): an assessment open only to people with a label
  is also hidden by default and no rule offers it, so the people with the label cannot
  open it either. Set its default to optional or mandatory.

**Publish stays switched off while anything is flagged.** That is deliberate: a structure
the platform refuses to store is not a structure it can apply.

## Publish

Choose **Publish**. The published version number is set to the draft you published, and
the panel reports how many people's availability actually moved.

If somebody else changed the same campaign while you were editing, the save or the
publish is refused with a version conflict and a **Reload the rules** button. Reload,
look at what changed, and redo your edit. Nothing is overwritten silently.

### Telling people about new assessments

After a publish that introduced assessments to a running campaign, the panel asks whether
to announce them, and **Open the announcement** takes you to the **Engagement** tab where
the message is previewed and sent. Nothing is ever mailed by publishing.

An assessment that was published before, taken out and put back is listed separately as
**restored**, and is never offered for an announcement: the people on the roster were
told about it the first time.

## Limits and gotchas

- The panel writes availability and rules. Who answers an assessment, and the group that
  names a unit, are set on the assessment itself.
- Rules read answers only. Labels on the roster cannot be used in an expression; a label
  can only open an assessment to the people who carry it (see above), and a person
  without it is never offered that assessment.
- An assessment open only to people with a label is never listed to someone who enters
  with a campaign passcode, and never opens to someone without a roster row.
- Removing an assessment from a campaign does not remove its node; the panel will show
  the platform's warning about a node whose assessment is gone.
- This is the minimal panel. The
  [Campaign Builder](/operate/tenant-admin/campaign-builder) draws the same structure as
  boxes and arrows and applies exactly these rules. **Open the builder** is beside
  Publish.

## Related
- [Draw a campaign in the Campaign Builder](/operate/tenant-admin/campaign-builder)
- [Publish and preview an assessment](/operate/tenant-admin/publish-and-preview-an-assessment)
- [Track recruitment progress](/operate/tenant-admin/track-recruitment-progress)
