# Verb sub task

A sub workflow is an element in a User step

![](https://543770944-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LtPTgZOYmpJka4jqs1v%2F-M-oh38gD3L5x-VPk2LG%2F-M-ohSaQThP73_siAKla%2Fhelp_root_applications_workflow_user_items_sub_user.png?alt=media\&token=1f2ea0f1-c492-4305-b516-a3b58857c55c) \
**There are three types of sub workflows:**\
**Check List:** Executes one workflow for each record in a list of things to do.\
**Item Creation:** Creates a new item for each time the sub workflow is executed.\
**Verb:** A side track in the workflow where the sub workflow can be executed one or many times.

### Verb Sub Task <a href="#verb-sub-task" id="verb-sub-task"></a>

A sub workflow is created from a *User Step*. Create a new *User Step* and add a verb sub-task element. Configure the appearance of verb sub-task element in the client.

Set the following:

* **Title:** Text on the verb sub-task element button.
* **Icon:** Icon one the on the verb sub-task element button.
* **Allow Multiple Runs:** This should be check to allow the verb sub-task element to be run multiple times whist in the same user step in the main workflow.
* **Pills:** Pill on the sub workflow button. One or multiple pills can be configured on the verb subtask, the pill can display a text or a count of how many times the verb sub-task has been run\*

![Item creation sub task example](https://543770944-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LtPTgZOYmpJka4jqs1v%2F-M-oh38gD3L5x-VPk2LG%2F-M-oighyxPaj0kiT4NbM%2Fhelp_root_applications_workflow_user_items_sub_verb.png?alt=media\&token=560fe7c1-a793-4bf5-8a0d-db7e64e2bae5)

Close the *User Step*, an icon will now appear, representing the added sub workflow.

Double click on the sub workflow icon to open the (empty) sub workflow.

Create a workflow, all variables from the main workflow are available in the sub workflow.

Return data back to the main workflow by configuring the *End step* in the sub workflow. The output from the sub workflow is put in the target variable of the verb sub-task element. The sub workflow output is available once the user has moved on from the user step the verb sub-task is located in, i.e. it is not possible to use the data in the user step the sub workflow is started from.

The output from a sub workflow will always be in grid format. ![Item creation sub task example](https://home.novacuraflow.com/Help/latest/images/help_root_applications_workflow_user_items_sub_end.png)

#### Verb sub-task output example <a href="#verb-sub-task-output-example" id="verb-sub-task-output-example"></a>

![](https://543770944-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LtPTgZOYmpJka4jqs1v%2F-M-oh38gD3L5x-VPk2LG%2F-M-oh_oTUiMdphwL0MO_%2Fhelp_root_applications_workflow_user_items_sub_end.png?alt=media\&token=96473807-89fe-4ec4-aa1c-2b62694407a5)

### Verb sub-task output example

![](https://543770944-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LtPTgZOYmpJka4jqs1v%2F-M-oh38gD3L5x-VPk2LG%2F-M-oixkouK0-jSMl6lCo%2Fhelp_root_applications_workflow_user_items_sub_verb_example1.png?alt=media\&token=e4fec34c-73e3-4b45-a495-55c7761e0532)

The user step contains three verb sub-tasks with the following content:

1. Add Additional Info a. addInfo ? text input b. finishDate ? date input
2. Add Picture (Allow multiple runs = TRUE) a. addPicture ? camera input
3. Add Material (Allow multiple runs = TRUE) a. gridMaterial ? data grid
4. User Step:

![](https://543770944-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LtPTgZOYmpJka4jqs1v%2F-M-oh38gD3L5x-VPk2LG%2F-M-ojR3qnS1sfUY6SX9c%2Fhelp_root_applications_workflow_user_items_sub_verb_example2.png?alt=media\&token=ee0dc2ee-7f70-4cb1-9f33-82f49d08db6e)

5\. Script Step: outPutPictures

![](https://543770944-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LtPTgZOYmpJka4jqs1v%2F-M-oh38gD3L5x-VPk2LG%2F-M-ojeUilNeHipM_G9MS%2Fhelp_root_applications_workflow_user_items_sub_verb_example3.png?alt=media\&token=41caf153-a9c4-458a-bc31-108b5bfebdb8)

6\. Script Step: selectedMaterialAll

![](https://543770944-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LtPTgZOYmpJka4jqs1v%2F-M-oh38gD3L5x-VPk2LG%2F-M-ojtt2SKRPcg-N7Md4%2Fhelp_root_applications_workflow_user_items_sub_verb_example4.png?alt=media\&token=d1a3920e-fc46-44f7-b399-b196fe4ddb14)

7\. Assignment: selectedMaterial

![](https://543770944-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LtPTgZOYmpJka4jqs1v%2F-M-oh38gD3L5x-VPk2LG%2F-M-ok83Od9WdIOnolWXa%2Fhelp_root_applications_workflow_user_items_sub_verb_example5.png?alt=media\&token=14dd912b-e3ff-47b9-b2f9-f4ef5069c9e8)

8\. User Step

![](https://543770944-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LtPTgZOYmpJka4jqs1v%2F-M-oh38gD3L5x-VPk2LG%2F-M-okGO5fYTg_rfKmp_I%2Fhelp_root_applications_workflow_user_items_sub_verb_example6.png?alt=media\&token=9593373f-077b-4cc5-ae37-31d1a55a3e10)

Sub verb-tasks run in iOS - Pills:

![](https://543770944-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LtPTgZOYmpJka4jqs1v%2F-M-oh38gD3L5x-VPk2LG%2F-M-okfjyeFJ_LZKx1yrs%2Fhelp_root_applications_workflow_user_items_sub_verb_example7.png?alt=media\&token=9e8cc3f0-9ec5-40e8-b492-9eb599958452)

#### Flow script examples <a href="#flow-script-examples" id="flow-script-examples"></a>

Scrip Step - Add pictures to table:

```
let table1 = table(data, filename); 
    for rec_ in value3 do
        set table1 = table1 & [data: rec_.addPicture.data, filename: rec_.addPicture.filename];
    done
return table1;
```

Scrip Step - Grid ? verb sub task run multiple times (loop in loop):

```
let table1 = table(part_no, part_desc);
    for rec_ in value4 do
        for rec1_ in rec_.gridMaterial do
            set table1 = table1 & [part_no: rec1_.part_no, part_desc: rec1_.part_desc];
        done
    done
return table1;
```

Assignment ? fetch first picture:

```
Picture = {(*First(value3).addPicture)}
```

Assignment ? fetch last grid:

```
selectedMaterial = {value4.Skip(value4.Count()-1).First().gridMaterial}
```
