• This web contains the official documentation of the TWiki-6.1 Release, code named KampalaRelease.
• It is a read-only web for reference. Please update documentation at TWiki.IfThenActionRulesTemplate.
Tags:
create new tag
view all tags

If-Then-Action Rules

ALERT! NOTE: This is a template topic, do not use. Define if-then-action rules in Main.IfThenActionRules

This topic defines if-then action rules. The actions are handled by the IfThenActionPlugin.

If Source Then Target Comment
         
         
         
         
  Sandbox tests:      
save IfThenActionTest email IfThenActionEmailTemplate This sends an e-mail based on the target template when the source topic is updated
save IfThenActionTest setformfield $children(1 If*)/$formfield(Number) = $formfield(Number) This updates all children's Number form field to the current topic's Number form field
save IfThenActionTest touch IfThenActionTouch This does an edit & save of the target topic
save IfThenActionTest view IfThenActionView This does a normal topic view
save IfThenActionTest viewdaemon IfThenActionViewDaemon This does a daemon view, e.g. is non-blocking

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.
        ALERT! 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

Topic revision: r0 - 2015-04-16 - TWikiContributor
 
  • Learn about TWiki  
  • Download TWiki
This site is powered by the TWiki collaboration platform Powered by PerlCopyright © 1999-2025 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback
Note: Please contribute updates to this topic on TWiki.org at TWiki:TWiki.IfThenActionRulesTemplate.