Manual:Extension/Workflows/Activity/SetTemplateParams: Difference between revisions

(Created page with "==<span class="mw-headline">Description</span>== The ''EditWikiPage'' activity appends content to an existing wiki page. {| class="wikitable" style="" ! colspan="2" style="ba...")
 
No edit summary
 
(9 intermediate revisions by 2 users not shown)
Line 1: Line 1:
==<span class="mw-headline">Description</span>==
==Description==
The ''EditWikiPage'' activity appends content to an existing wiki page.  
The ''SetTemplateParams'' activity allows automatic setting a template parameter on a wiki page.
{| class="wikitable" style=""
 
! colspan="2" style="background-color:rgb(234, 236, 240);text-align:center;" |'''Short profile'''
* Templates are accessed by the order of appearance on the page, starting at 0. Non-existing templates are counted as links, so they do not count in this list.
* Parameters inside the template can be specified by their name or the index in case of non-named parameters.
* Index for non-named params starts at 1 (not 0!), as to be consistent with how template params are accessed in the template itself.
* Nested templates are currently not supported.
 
== Profile ==
{| class="wikitable"
! colspan="2" |'''Short profile'''
|-
|-
| style="" |Name
|Name
| style="" |EditWikiPage
|SetTemplateParams
|-
|-
| style="" |Async
|Async
| style="" |Yes
|Yes
|-
|-
| style="" |BPMN type
|BPMN type
| style="" |<code>bpmn:Task</code>
|<code>bpmn:task</code>
|-
|-
|BPMN Extension Element "wf:type"
|BPMN Extension Element "wf:type"
|<code>edit_page</code>
|<code>set_template_param</code>
|}
|}


==<span class="mw-headline">Properties</span>==
==Properties==
 
{| class="wikitable"
=== Input properties ===
! style="vertical-align:middle;text-align:left;" |'''Name of property'''
Each input property can provide a default value if no other value is set by the workflow.
!'''Description'''
{| class="wikitable" style="width:100%;"
!'''Type'''
! style="background-color:rgb(234, 236, 240);text-align:center;" |Name of property
|-
!Source
|<code>title</code>
! style="background-color:rgb(234, 236, 240);text-align:center;" |Description
|Name of the page where the template parameter is changed. If it will be changed on the page where the workflow runs, the value is <code><nowiki>{{FULLPAGENAME}}</nowiki></code>
!Possible values
|string
! style="background-color:rgb(234, 236, 240);text-align:center;" |Type
|-
|-
| style="" |<code>title</code>
| style="width:70px;" |<code>user</code>
|<nowiki>-</nowiki>
|User that is shown in the revision history
| style="" |Name of the wiki page that will be edited by this activity.
|user
|
| style="" |string
|-
|-
|<code>user</code>
|<code>template-index</code>
| -
|Index of the template on the page (starting at 0)
|Name of user that will be shown as making the edit.
|number
|Default value: ''MediaWiki default''
|string
|-
|-
|<code>content</code>
|<code>template- param</code>
|  -
|Parameter to modify. This can be a string (in the case of a  named parameter) or a number (in case of a non-named param; starting from 1, accessor for the parameter)
|Content that will be added to the wiki page.
|<nowiki>int|string</nowiki>
|
|string
|-
|-
|<code>mode</code>
|<code>value</code>
| -
|New value of the parameter, set by the workflow
|How the content is added to the wiki page.
|
* ''append:'' Content is added at the end of the page.
* ''replace:'' Content replaces all existing page content.
* ''prepend:'' Content is added at the beginning of the page.
|string
|string
|-
|-
|<code>minor</code>
|<code>minor</code>
| -
|Marks the revision as a minor edit if set to 1
|The edit will be marked as ''major'' or ''minor'' revision.
|boolean
|
* ''1'' (=minor revision)
* ''0'' (=major revision)
|int
|}
 
=== Output properties ===
{| class="wikitable" style="width:100%;"
! style="background-color:rgb(234, 236, 240);text-align:center;" |Name of property
!Source
! style="background-color:rgb(234, 236, 240);text-align:center;" |Description
! style="background-color:rgb(234, 236, 240);text-align:center;" |Type
|-
|-
|<code>revisionId</code>
|<code>revisionId</code>
| -
|Sets a new page revision ID
|The revision ID of the edited page.
|number
|string
|-
|-
|<code>timestamp</code>
|<code>timestamp</code>
| -
|Sets the page revision timestamp
|The revision time of the edited page.
|timestamp
|timestamp
|-
|<code>comment</code>
|Comment that is shown in the revision history
|string
|}
|}


== Example ==
== Example ==
=== Workflow task ===
This workflow task will set the value of the parameter <code><nowiki>{{{status|not set}}}</nowiki></code> to <code>Updated</code> on a page's first template.<syntaxhighlight lang="xml">
<bpmn:task id="EditTemplate" name="Edit template">
    <bpmn:extensionElements>
<wf:type>set_template_param</wf:type>
</bpmn:extensionElements>
<bpmn:property name="title" default="Testpage" validation="required,existing-title"/>
<bpmn:property name="user" default="WikiSysop" validation="existing-user"/>
<!-- Index of the template on page (starting from 0) -->
<bpmn:property name="template-index" default="0"/>
<!-- Param to modify. Can be a string in case of named params, or a number, in case of non-named params (starting from 1, accessor for the param) -->
<bpmn:property name="template-param" default="status"/>
<!-- New value to set -->
<bpmn:property name="value" default="Updated"/>
<bpmn:property name="minor" default="0"/>
<!-- Output properties -->
<bpmn:property name="revisionId"/>
<bpmn:property name="comment" default="Edited template param"/>
<bpmn:property name="timestamp"/>
      <bpmn:incoming>Flow_1qh6vpl</bpmn:incoming>
      <bpmn:outgoing>Flow_0if1kyp</bpmn:outgoing>
    </bpmn:task>
</syntaxhighlight>
=== Template ===
The template content has the parameter <code><nowiki>{{{status}}}</nowiki></code> At the time of writing this, the workflow produced an error tif the parameter was wrapped in a <code><nowiki><div></nowiki></code> tag. Therefore, in the example below, the parameter is defined in a variable first. If the parameter is not in  a  <code>div</code> tag, using a variable is not necessary.<syntaxhighlight lang="text">
{{#vardefine:status|{{{status|not set}}}}}
<div style="background:#fbfaef;">Page status: {{#var:status}}</div>
</syntaxhighlight>
=== Full bpmn example ===
<syntaxhighlight lang="xml">
<syntaxhighlight lang="xml">
<bpmn:task id="Activity_18egh9o" name="Edit page">
<?xml version="1.0" encoding="UTF-8"?>
    <bpmn:extensionElements>
<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:wf="http://hallowelt.com/schema/bpmn/wf">
<wf:type>edit_page</wf:type>
    <bpmn:process id="SetTemplateParams-Process" isExecutable="false">
</bpmn:extensionElements>
        <bpmn:extensionElements>
<bpmn:property name="title" default="Some page" validation="required"/>
            <wf:context>
<bpmn:property name="user" default="Mediawiki default" validation="existing-user"/>
                <wf:contextItem name="pageId"/>
<bpmn:property name="content" default="This is my test at editing"/>
            </wf:context>
<bpmn:property name="mode" default="append"/> <!-- ALlowed: append, replace, prepend -->
        </bpmn:extensionElements>
<bpmn:property name="minor" default="1"/>
        <bpmn:startEvent id="TheStart">
<!-- Output properties -->
            <bpmn:outgoing>FromTheStartToEditTemplate</bpmn:outgoing>
<bpmn:property name="revisionId"/>
        </bpmn:startEvent>
<bpmn:property name="timestamp"/>
        <bpmn:sequenceFlow id="FromTheStartToEditTemplate" sourceRef="TheStart" targetRef="EditTemplate" />
</bpmn:task>
        <bpmn:task id="EditTemplate" name="Edit template">
            <bpmn:extensionElements>
                <wf:type>set_template_param</wf:type>
            </bpmn:extensionElements>
            <bpmn:property name="title" default="" validation="required,existing-title">{{FULLPAGENAME}}</bpmn:property>
            <bpmn:property name="user" default="WikiSysop" validation="existing-user">WikiSysop</bpmn:property>
            <!-- Index of the template on page (starting from 0) -->
            <bpmn:property name="template-index" default="0"/>
            <!-- Param to modify. Can be a string in case of named params, or a number, in case of non-named params (starting from 1, accessor for the param) -->
            <bpmn:property name="template-param" default="status"/>
            <!-- New value to set -->
            <bpmn:property name="value" default="Super edited param"/>
            <bpmn:property name="minor" default="1"/>
            <!-- Output properties -->
            <bpmn:property name="revisionId"/>
            <bpmn:property name="timestamp"/>
            <bpmn:incoming>FromTheStartToEditTemplate</bpmn:incoming>
            <bpmn:outgoing>FromEditTemplateToTheEnd</bpmn:outgoing>
        </bpmn:task>
        <bpmn:sequenceFlow id="FromEditTemplateToTheEnd" sourceRef="EditTemplate" targetRef="TheEnd" />
        <bpmn:endEvent id="TheEnd">
            <bpmn:incoming>FromEditTemplateToTheEnd</bpmn:incoming>
        </bpmn:endEvent>
    </bpmn:process>
</bpmn:definitions>
 
</syntaxhighlight>
</syntaxhighlight>
[[de:Handbuch:Erweiterung/Workflows/Activity/SetTemplateParams]]

Latest revision as of 15:58, 5 February 2024

Description

The SetTemplateParams activity allows automatic setting a template parameter on a wiki page.

  • Templates are accessed by the order of appearance on the page, starting at 0. Non-existing templates are counted as links, so they do not count in this list.
  • Parameters inside the template can be specified by their name or the index in case of non-named parameters.
  • Index for non-named params starts at 1 (not 0!), as to be consistent with how template params are accessed in the template itself.
  • Nested templates are currently not supported.

Profile

Short profile
Name SetTemplateParams
Async Yes
BPMN type bpmn:task
BPMN Extension Element "wf:type" set_template_param

Properties

Name of property Description Type
title Name of the page where the template parameter is changed. If it will be changed on the page where the workflow runs, the value is {{FULLPAGENAME}} string
user User that is shown in the revision history user
template-index Index of the template on the page (starting at 0) number
template- param Parameter to modify. This can be a string (in the case of a named parameter) or a number (in case of a non-named param; starting from 1, accessor for the parameter) int|string
value New value of the parameter, set by the workflow string
minor Marks the revision as a minor edit if set to 1 boolean
revisionId Sets a new page revision ID number
timestamp Sets the page revision timestamp timestamp
comment Comment that is shown in the revision history string

Example

Workflow task

This workflow task will set the value of the parameter {{{status|not set}}} to Updated on a page's first template.

<bpmn:task id="EditTemplate" name="Edit template">
    	<bpmn:extensionElements>
			<wf:type>set_template_param</wf:type>
		</bpmn:extensionElements>
		<bpmn:property name="title" default="Testpage" validation="required,existing-title"/>
		<bpmn:property name="user" default="WikiSysop" validation="existing-user"/>
		<!-- Index of the template on page (starting from 0) -->
		<bpmn:property name="template-index" default="0"/>
		<!-- Param to modify. Can be a string in case of named params, or a number, in case of non-named params (starting from 1, accessor for the param) -->
		<bpmn:property name="template-param" default="status"/>
		<!-- New value to set -->
		<bpmn:property name="value" default="Updated"/>
		<bpmn:property name="minor" default="0"/>

		<!-- Output properties -->
		<bpmn:property name="revisionId"/>
		<bpmn:property name="comment" default="Edited template param"/>
		<bpmn:property name="timestamp"/>
      <bpmn:incoming>Flow_1qh6vpl</bpmn:incoming>
      <bpmn:outgoing>Flow_0if1kyp</bpmn:outgoing>

    </bpmn:task>

Template

The template content has the parameter {{{status}}} At the time of writing this, the workflow produced an error tif the parameter was wrapped in a <div> tag. Therefore, in the example below, the parameter is defined in a variable first. If the parameter is not in a div tag, using a variable is not necessary.

{{#vardefine:status|{{{status|not set}}}}}
<div style="background:#fbfaef;">Page status: {{#var:status}}</div>

Full bpmn example

<?xml version="1.0" encoding="UTF-8"?>
<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:wf="http://hallowelt.com/schema/bpmn/wf">
    <bpmn:process id="SetTemplateParams-Process" isExecutable="false">
        <bpmn:extensionElements>
            <wf:context>
                <wf:contextItem name="pageId"/>
            </wf:context>
        </bpmn:extensionElements>
        <bpmn:startEvent id="TheStart">
            <bpmn:outgoing>FromTheStartToEditTemplate</bpmn:outgoing>
        </bpmn:startEvent>
        <bpmn:sequenceFlow id="FromTheStartToEditTemplate" sourceRef="TheStart" targetRef="EditTemplate" />
        <bpmn:task id="EditTemplate" name="Edit template">
            <bpmn:extensionElements>
                <wf:type>set_template_param</wf:type>
            </bpmn:extensionElements>
            <bpmn:property name="title" default="" validation="required,existing-title">{{FULLPAGENAME}}</bpmn:property>
            <bpmn:property name="user" default="WikiSysop" validation="existing-user">WikiSysop</bpmn:property>
            <!-- Index of the template on page (starting from 0) -->
            <bpmn:property name="template-index" default="0"/>
            <!-- Param to modify. Can be a string in case of named params, or a number, in case of non-named params (starting from 1, accessor for the param) -->
            <bpmn:property name="template-param" default="status"/>
            <!-- New value to set -->
            <bpmn:property name="value" default="Super edited param"/>
            <bpmn:property name="minor" default="1"/>
            <!-- Output properties -->
            <bpmn:property name="revisionId"/>
            <bpmn:property name="timestamp"/>
            <bpmn:incoming>FromTheStartToEditTemplate</bpmn:incoming>
            <bpmn:outgoing>FromEditTemplateToTheEnd</bpmn:outgoing>
        </bpmn:task>
        <bpmn:sequenceFlow id="FromEditTemplateToTheEnd" sourceRef="EditTemplate" targetRef="TheEnd" />
        <bpmn:endEvent id="TheEnd">
            <bpmn:incoming>FromEditTemplateToTheEnd</bpmn:incoming>
        </bpmn:endEvent>
    </bpmn:process>
</bpmn:definitions>




To submit feedback about this documentation, visit our community forum.