If-Then-Action Rules
This topic defines if-then action rules. The actions are handled by the
IfThenActionPlugin.
Help on rules table:
- If: The if-action is the trigger.
- Currently implemented if-actions:
-
action - take action on a %IFTHEN{ "action" }% variable.
- The variable takes an optional
topic parameter to overload the current topic, such as: %IFTHEN{ "action" topic="Web.TopicName" }%.
-
register - take action after successful user registration.
Note: The Source must be set to: %WEB%.%TOPIC%
-
save - take action after saving a topic.
-
upload - take action after uploading a file attachment.
-
view - take action on topic view. The action is triggered at the end of the page rendering process.
- Note: If-actions can be disabled in configure, some might not be available.
- Available if-actions: action, register, save, upload
- Source: Source topic or source condition. Syntax:
- Specify the
Web.TopicName of the topic that should trigger an action, or a comma-space list of topics such as Web1.Topic1, Web2.Topic2.
- Wildcards can be used for the topic name, such as
CID-* to indicate names starting with CID-.
- A condition can be crafted using TWikiVariables such as
%IF{}% or %CALCULATE{$IF()}%.
- Use
%WEB% and %TOPIC% to indicate the source web and topic, respectively.
- The result of the condition should a
Web.TopicName to take action on, a topic list, or an empty string to cancel the action.
- Then: The then-action is the action taken.
- Currently implemented then-actions:
-
attachsection - attach the content of a section as a file attachment.
-
email - send an e-mail based on an e-mail template topic.
-
setformfield - update a form field of a target topic.
-
setpreference - set or update a preferences setting of a target topic.
-
touch - edit and save a target topic without making any content change.
-
view - view a topic and wait for the rendering.
-
viewdaemon - view a topic asynchronously, e.g. non-blocking; useful if the view of the target topic is slow.
- Note: Then-actions can be disabled in configure, some might not be available.
- Available then-actions: attachsection, email, setformfield, touch, twikiorgdsp, twikiorgview, view, viewdaemon
- Target: Target topic and more. Syntax:
-
Web.TopicName of the topic to take action on, or a comma-space list of topics such as Web1.Topic1, Web2.Topic2.
- The web name is optional; the source web is used if omitted.
- Tokens can be used instead of the topic name:
-
$topic - name of source topic.
-
$parents - parent trail, up to 64 parents up.
-
$parents(5) - parent trail, up to 5 parents up.
-
$parent - topic parent.
-
$parent(5) - the 5th parent up in the parent trail.
-
$children: expands to all direct children.
-
$children(5): expands to all children recursively 5 levels deep.
-
$children(10 CID-*): expands to all children 10 levels deep, using only topic names starting with CID-* (if possible specify a topic name filter with wildcards for better performance).
- The then-action is cancelled in case the target topic does not exist, such as if there is no parent when using
$parent
- Example target:
Web.SomeTopic, Web.NotExistingTopic, Web.$parent, Web.$children
- Example output:
Web.SomeTopic, Web.ItsParent, Web.ItsChild1, Web.ItsChild2, Web.ItsChild3
- The target can be crafted dynamically using TWikiVariables such as
%FORMFIELD{}% and %CALCULATE{}%.
- Use
%WEB% and %TOPIC% to indicate the source web and topic, respectively.
- The syntax differs based on the then-action.
- Example
setformfield then-action target: $children/$formfield(Status) = $formfield(Status)
- Example
setpreference then-action target: $topic/ALLOWTOPICCHANGE = $formfield(Owner)
Access control:
Related: IfThenActionPlugin