Skip to content

Commit bd5075b

Browse files
authored
Merge pull request #6 from PROCEED-Labs/update-user-task-variable-section
User Task variable description update
2 parents b76998f + 840c8c1 commit bd5075b

1 file changed

Lines changed: 103 additions & 6 deletions

File tree

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

Lines changed: 103 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -197,19 +197,19 @@ Tasklist](/images/tasklist/submit-variables.png)
197197
Existing variables of the processInstance can be retrieved to be shown inside
198198
the User Task.
199199

200-
For this, the HTML Code of the User Task must make use of the [Whiskers template
201-
syntax](https://github.com/gsf/whiskers.js) to access and use process variables.
202-
It is easy and keeps templates readable by limiting tags to variables,
203-
statements ("for", "if", and "else"), partials, and comments. Usually you only
204-
need { } for accessing the desired variable.
200+
For this, the HTML Code of the User Task must make use of placeholders to access and use process variables.
201+
It is easy and keeps templates readable by limiting tags to variables and
202+
statements ("for" and "if").
203+
204+
Usually you only need `\{%[variable-name]%\}` for accessing the desired variable.
205205

206206
In this example, the variables `firstname` and `surname` are shown inside this
207207
User Task
208208

209209
```
210210
<form class="form">
211211
<div id="i3jcu">
212-
<b id="i4m1">Hello, {firstname} {surname}!
212+
<b id="i4m1">Hello, {%firstname%} {%surname%}!
213213
</b>
214214
</div>
215215
<img id="inmmd" src="https://cdn.pixabay.com/photo/2015/07/02/10/40/writing-828911_1280.jpg"/>
@@ -222,6 +222,103 @@ User Task
222222
This is what is shown in the tasklist of the engine when encountering the User Task `Show full name`:
223223
![User Task in Tasklist](/images/tasklist/show-variables.png)
224224

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+
225322
{/*
226323
227324
## OLD: FROM Alessandro

0 commit comments

Comments
 (0)