# Develop your first app

Here is a guide for how to create a simple app.

The app will allow the end-user to create an issue report that will be saved to a database.&#x20;

As a Flow designer you will get to know how to:

* Create a new workflow
* Create a first user step where the user can enter data
* Fetch and use data from a database
* Insert data to a database
* Publish an app

You will need an SQL server database to complete this app, download the database [here](https://home.novacuraflow.com/Downloads/Help/Training_Database.zip).&#x20;

## :ocean: Create a workflow

[Log in to Flow studio](https://help.novacuraflow.com/6.12/quick-start#flow-studio), and create a new workflow:&#x20;

Click on *File* and choose *New*.&#x20;

![](https://3419513391-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LtPTgZOYmpJka4jqs1v%2F-M-KhcprSDcTzkCB2VWr%2F-M-Kx9c7Le6CD0-BvWcl%2Fnewapp.gif?alt=media\&token=94de5308-d580-443b-8f45-5aed1aee5b3c)

## :footprints: First step

1. Create the first step by right clicking on the green start step and choose *Add sequence arrow.*
2. Right-click again and choose *Create user step.*
3. Enter a suitable name for the user step label.
4. Double-click on the User step to enter the user step editor.&#x20;

<div align="left"><img src="https://3419513391-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LtPTgZOYmpJka4jqs1v%2F-M-PPbga--b-Vr-QMFYD%2F-M-PVbrM9rXhr_AwGXwC%2Fadduserstep.gif?alt=media&#x26;token=147b1870-364e-4ac4-b06c-f27dcb286823" alt=""></div>

1. Drag a *Header* object in to the center of the user step editor.
2. Enter a text in the header, e.g. Welcome.
3. Drag in a *Text input* field.&#x20;
4. Enter a prompt text, e.g. Enter name.&#x20;
5. Enter a target variable, e.g. Name.&#x20;
6. Drag in another *Text input* field and enter a prompt and a target value for email adderss.
7. Click OK to save your changes.

{% hint style="info" %}
**Tips:** Use the test bench to verify what you have done.&#x20;

Start the test bench by clicking on the play button in the right corner or use the keyboard shortcut Ctrl+Enter. &#x20;
{% endhint %}

![](https://3419513391-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LtPTgZOYmpJka4jqs1v%2F-M-PcaTf5mjTMS8bg6Yd%2F-M-Pyg5fM3D3uHq-afXj%2Fbild.png?alt=media\&token=7e89c165-6378-471d-bdd3-9fbbb2c3da0a)

## :satellite: Get data

1. Right click and choose *Create machine step.*
2. Right click on the Machine step and choose *Add data arrow,* connect the data arrow with the User step.&#x20;
3. Double-click on the Machine step to open the machine step editor.&#x20;
4. Select connector in the dropdown list.&#x20;
5. Select database call type and enter the query.&#x20;
6. Enter a variable name, e.g. DS\_issueTypes.
7. Click OK to save your changes.

{% hint style="info" %}
**Tip:** Use the magic wand to beautify the sql script in the machine step.:man\_mage:&#x20;
{% endhint %}

![](https://3419513391-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LtPTgZOYmpJka4jqs1v%2F-M0RftPLdFsHajjh5UEa%2F-M0WiBqnpWi90XcD8xTM%2Fgetdata.gif?alt=media\&token=07ebdf40-c0e4-447c-af54-5e45b77206fc)

#### Code to use:

```sql
SELECT [TYPE] "TYPE"
FROM   [dbo].[IssueType] 
```

Open the User step and configure a list to show the issue types.&#x20;

1. Drag in a *Menu selection input.*
2. Enter a target variable for the output, e.g. issueType.&#x20;
3. Select table variable DS\_issueTypes as data source.&#x20;
4. Enter a prompt, e.g. Select issue type.
5. Enter row text, type a { to get a list of available variables, choose the TYPE variable.
6. Choose TYPE as *Field to select*, and select *Show empty option*.
7. Drag in a *Text input* field.
8. Enter a prompt text, e.g. Enter issue description.&#x20;
9. Enter a target variable, e.g. issueDesc.&#x20;
10. Select multiline.
11. Click OK to save your changes.

{% hint style="info" %}
**Tips:** Use the test bench to verify what you have done.&#x20;

Start the test bench by clicking on the play button in the right corner or use the keyboard shortcut Ctrl+Enter. &#x20;
{% endhint %}

![](https://3419513391-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LtPTgZOYmpJka4jqs1v%2F-M0RftPLdFsHajjh5UEa%2F-M0WleaYxXcSxHuQaSYz%2Fbild.png?alt=media\&token=e16baafb-d6a3-4caf-ae9d-4eb6c886c142)

## :seedling: Use variables

1. Add another machine step, you can drag and drop a machine step from the Workflow elements area or right-click in the workflow area and select *Create machine step*.&#x20;
2. Use a *sequence arrow* and connect first user step with the machine step you just adde&#x64;*.*&#x20;
3. Double-click on the machine step to enter the machine step editor.
4. Select connector in the dropdown list. The database call type should be set to script.&#x20;
5. Enter your sql script, enter a { to get a list of available variables, choose the name variable, do the same for the other variables.
6. Click OK to save your changes.&#x20;

{% hint style="info" %}
**Tip:** Write *@out\_* to create an output variable for scripts. You can add several *@out\_* to add more values to the output record.
{% endhint %}

![](https://3419513391-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LtPTgZOYmpJka4jqs1v%2F-M0bApUnsddId2j98Uyn%2F-M0bxPB6DQPiVX51G7dd%2Fsavedata2.gif?alt=media\&token=94173cb2-b38c-4d00-a5c6-95e98ebdd48b)

#### Code to use:

```sql
INSERT INTO [WorkOrder]
           ([NAME]
           ,[EMAIL]
           ,[ISSUE_TYPE]
           ,[ISSUE_DESC]
           ,[REPORT_DATE]
           ,[STATUS])
     VALUES
           (@name
	         ,@email
           ,@issueType
           ,@issueDesc
           ,GETDATE()
           ,'New')


SET @out_issueNumber = SCOPE_IDENTITY()
```

Add another user step, add one header and one static text field with information about the issue number. \
Enter a { to get a list of available variables, choose the issueNumber variable.

{% hint style="info" %}
**Tip:** Click on the wrench icon:wrench:(Route 1) to change the button name to a more suitable name so the user understands what will happen when clicking on the button.&#x20;
{% endhint %}

![](https://3419513391-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LtPTgZOYmpJka4jqs1v%2F-M0XnNPFXUzda_2d-3Xb%2F-M0XyBfT5jXj_De-SqA0%2Fbild.png?alt=media\&token=f8497ae9-860c-4173-97cc-cd765ec03b10)

## :handshake: Commit and publish

An app must be published to be available in the Flow clients.&#x20;

1. Commit the app by clicking on the check mark in the top left corner of the workflow area.&#x20;
2. Leave a comment that describes the change that were made, and click on *Commit*.
3. Finally publish the workflow by clicking on the (space ship) *Publish* button.&#x20;

{% hint style="info" %}
For each commit a version will be created, all versions will be listed in the *Version history* panel. Open an old version by double-clicking on a version in the *Version history* panel.
{% endhint %}

![](https://3419513391-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LtPTgZOYmpJka4jqs1v%2F-M0adxFr91noi8mARz7_%2F-M-jCQmRlV_0zvOleppU%2Fcommitpublish.gif?alt=media\&token=b8fb987a-4f2b-4943-ba3c-285e9aaf3d38)

## :briefcase: Add to menu

1. Create a menu, right-click in the server content area and choose New -> Menu.&#x20;
2. Enter a *Title* for the menu.&#x20;
3. Click on the + and choose *Workflow item,* select your workflow.
4. Click on *Edit roles* in the bottom corner of the menu and check the roles that should have permission to the menu. Learn how to setup a role [here](https://help.novacuraflow.com/6.12/quick-start#app-permissions).&#x20;

The app is now ready to run in any Flow client.&#x20;

![](https://3419513391-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LtPTgZOYmpJka4jqs1v%2F-M0Y8_Jxy5bHJeLqk4sJ%2F-M0YCTnE3Omti1xQVchq%2Faddtomenu.gif?alt=media\&token=1e801d5a-83b1-43a5-b741-f7cb97c70379)

## :carousel\_horse: Run the app

You can run all apps in the Flow clients on iOS, Android, Windows 10 and Web. You can download the Flow client app from Google store, App store and Microsoft store.&#x20;

1. Open the Flow client app, connect to your Flow server and enter username and password.&#x20;
2. When you are logged in, you will see the app under the menu tab, click on the app to start.&#x20;
3. Fill in the fields and click *OK*, cancel the execution by clicking the *Quit* button.&#x20;

{% hint style="info" %}
**Tip**: If your app doesn't appear in the client, check that the **menu** and **user** is assigned to the correct role.
{% endhint %}

![](https://3419513391-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LtPTgZOYmpJka4jqs1v%2F-M0bApUnsddId2j98Uyn%2F-M0cDXPtvI20prCmnUHn%2Frunappios.gif?alt=media\&token=030dfcde-b9b4-4b0e-9889-b47cab9e1baf)
