Skip to content

Commit 840c8c1

Browse files
committed
Added more examples for user task placeholders
1 parent 26e2f5c commit 840c8c1

1 file changed

Lines changed: 100 additions & 2 deletions

File tree

content/developer/bpmn/bpmn-user-tasks.mdx

Lines changed: 100 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -199,8 +199,9 @@ the User Task.
199199

200200
For this, the HTML Code of the User Task must make use of placeholders to access and use process variables.
201201
It is easy and keeps templates readable by limiting tags to variables and
202-
statements ("for" and "if"). Usually you only
203-
need {% %} for accessing the desired variable.
202+
statements ("for" and "if").
203+
204+
Usually you only need `\{%[variable-name]%\}` for accessing the desired variable.
204205

205206
In this example, the variables `firstname` and `surname` are shown inside this
206207
User Task
@@ -221,6 +222,103 @@ User Task
221222
This is what is shown in the tasklist of the engine when encountering the User Task `Show full name`:
222223
![User Task in Tasklist](/images/tasklist/show-variables.png)
223224

225+
For more complex object types variables of the form `{ [attribute-name]: [attribute-value], ... }` subscripts can be used to access nested values.
226+
To do that use a placeholder of the form:
227+
\
228+
`\{%[variable-name].[attribute-name]%\}`
229+
230+
In this example the entry `name` of the variable `user` which has the value `{ name: 'Max Mustermann' }` is shown inside the user task.
231+
The ouput is the same as for the previous example.
232+
233+
```
234+
<form class="form">
235+
<div id="i3jcu">
236+
<b id="i4m1">Hello, {%user.name%}!
237+
</b>
238+
</div>
239+
<img id="inmmd" src="https://cdn.pixabay.com/photo/2015/07/02/10/40/writing-828911_1280.jpg"/>
240+
<div id="if91m">Welcome to this User Task! Just click the Submit button to complete this task!
241+
</div>
242+
<button type="submit" class="button">Submit</button>
243+
</form>
244+
```
245+
246+
For more complex cases if and for statements are supported.
247+
248+
If part of the html should only be shown when a specific variable is true or has a value you can use if statements of the form:
249+
\
250+
`\{%if [variable-name]%\}[conditional-part]\{%/if%}`
251+
252+
You can also use comparisons to show parts of the html only if a variable has (or does not have) a specific value:
253+
\
254+
`\{%if [variable-name] == '[string-value]'%\}[conditional-part]\{%/if%\}`
255+
\
256+
`\{%if [variable-name] != '[string-value]'%\}[conditional-part]\{%/if%\}`
257+
258+
In this example the text `Hello Max!` is shown when the variable `firstname` has the value `Max`.
259+
Otherwise the text `Welcome` is shown.
260+
261+
```
262+
<form class="form">
263+
<div id="i3jcu">
264+
{%if firstname == 'Max'%}Hello Max!{%/if%}
265+
{%if firstname != 'Max'%}Welcome{%/if%}
266+
</div>
267+
<button type="submit" class="button">Submit</button>
268+
</form>
269+
```
270+
271+
This is what will be the output html when the value of `firstname` is `Max`.
272+
273+
```
274+
<form class="form">
275+
<div id="i3jcu">
276+
Hello Max!
277+
</div>
278+
<button type="submit" class="button">Submit</button>
279+
</form>
280+
```
281+
282+
If a part of the html should shown for every entry in an array typed variable you can use a for statement of the form:
283+
\
284+
`\{%for [loop-variable] in [variable-name]%\}[html part]\{%/for%\}`
285+
286+
Inside the loop you can then use `loop-variable` to access the values of the entry.
287+
288+
In this example the variable `users` has the following value:
289+
290+
```
291+
[
292+
{ firstname: 'Max', surname: 'Mustermann' },
293+
{ firstname: 'John', surname: 'Doe' }
294+
]
295+
```
296+
297+
The given html is:
298+
299+
```
300+
<form class="form">
301+
<ul>
302+
{%for user in users%}
303+
<li>{%user.firstname%} {%user.surname%}</li>
304+
{%/for%}
305+
</ul>
306+
<button type="submit" class="button">Submit</button>
307+
</form>
308+
```
309+
310+
The resulting html is:
311+
312+
```
313+
<form class="form">
314+
<ul>
315+
<li>Max Mustermann</li>
316+
<li>John Doe</li>
317+
</ul>
318+
<button type="submit" class="button">Submit</button>
319+
</form>
320+
```
321+
224322
{/*
225323
226324
## OLD: FROM Alessandro

0 commit comments

Comments
 (0)