Wiki source code of execute Workflow/Expression with external Record
Show last authors
author | version | line-number | content |
---|---|---|---|
1 | This example is triggered everytime a Project Task is updated and execute a Workflow from Module “Project” to summarize working hours. | ||
2 | |||
3 | == ProjectTask Workflow == | ||
4 | |||
5 | The Workflow within Project Tasks looks like this: | ||
6 | |||
7 | [[image:Screen1480874922.png]] | ||
8 | |||
9 | ---- | ||
10 | |||
11 | The start action configuration: | ||
12 | |||
13 | [[image:Screen1480874993.png]] | ||
14 | |||
15 | The workflow will only executed, if a Project is set within the Task. (Should be the default case) | ||
16 | Then the “Execute Workflow with external Record” search the Project Record and execute another Workflow, you see below. | ||
17 | |||
18 | ---- | ||
19 | |||
20 | Configuration of execute Workflow with external records: | ||
21 | |||
22 | [[image:Screen1480875035.png]] | ||
23 | |||
24 | ---- | ||
25 | |||
26 | == Projects Workflow == | ||
27 | |||
28 | [[image:Screen1480875568-768x263.png]] | ||
29 | |||
30 | ---- | ||
31 | |||
32 | Start condition: | ||
33 | |||
34 | [[image:Screen1204192116001-768x448.png]] | ||
35 | |||
36 | ---- | ||
37 | |||
38 | The variable initialization: | ||
39 | |||
40 | [[image:Screen1204192157001.png]] | ||
41 | |||
42 | ---- | ||
43 | |||
44 | Summarize all records, which are related to this Project ID. | ||
45 | |||
46 | [[image:Screen1204192225001-768x343.png]] | ||
47 | |||
48 | ---- | ||
49 | |||
50 | Set the result into a field | ||
51 | |||
52 | [[image:Screen1204192248001-768x168.png]] | ||
53 | |||
54 | This workflow is not executed automatically. (Start Trigger set to “start manually”) | ||
55 | |||
56 | Because we sum the working hour field about multiple records, we net to initialize the variable and set $env[“hours”] to 0. | ||
57 | |||
58 | The “execute Expression with external Record” execute an small script for every record, which match the the condition. (In this case: Tasks, which are related to the current Project ID) | ||
59 | The script will add the value of $projecttaskhours to the current $env[“hours”] variable. | ||
60 | |||
61 | The last step is to set this value to the Project field “Total Working Time” |