Automatic Workflow

In this tutorial you will learn how to use and what are automatic Workflow actions on the example of an app for approving expenses.

Conception: The purpose of the tutorial is to create an app, in which first user fills out a report about an expense and then sends it to his supervisor, who can accept or reject this expense. If the supervisor doesn't perform the action in the specific time (for example due to absence), the report will go to his supervisor (supervisor of supervisor). When the app finally goes to someone who doesn't have a supervisor, the report will be rejected.

1. List of employees and supervisors

Create a new list and name it 'EMPLOYEES'. It will contain the names and identifiers of employees and their supervisors. Name the columns as below and fill the cells with your data and those of the people you work with. Save the list.


2. Expense report


Create a new app and add a two-column spreadsheet named 'DATA'. In the first column, enter 'Product name:', 'Price per item:', 'Number of products:', 'Total cost:' and 'short note'.


In the second column, set all cells except B4 to editable, Set cells B2 and B4 type to currency and cell B3 to number. In cell B4 enter the formula '=B2*B3' as below.



Add a new section of the attachment type, rename it to 'attachments' and change the header to 'Attach an invoice or receipt'.



Add a workflow action widget.

3. Auxiliary sections


Add a new two-column spreadsheet (name it USER) and in the first column, enter 'ID:', 'Name:', 'Supervisor:' and 'Supervisor ID:'. Bind this section with the 'EMPLOYEES' list and bind each cell in the second column with the corresponding column from the list, as below (by dragging the list name from the data tab on the section name and dragging the appropriate columns on the appropriate cells).



Add another spreadsheet named ID and with one cell. Enter the formula '=currentuserid()' in the cell, which returns the ID of the user who opened the app. Set this cell editable. 



Go back to the 'USER' section and go to the options tab. In the filter option, enter the formula
'=lookup(EMPLOYEES, ID=ID.A1)', this way the data of the user who opened the app will appear in the section. Set the refresh mode to 'Always'.


Set the visibility of both sections to 'FALSE'.

4. Workflow


Go to the Workflow tab. Create three states and name them: 'Acceptance', 'Accepted', and 'Rejected'. Combine them with the actions 'Send to supervisor', 'Accept' and 'Reject' as below.


On the 'Send to supervisor' action set the action 'Set section editability', as the section enter 'DATA' and set the editability to FALSE. Now, when the first user completes expense's data, the next person will not be able to change it.



Create two more actions from the 'Acceptance' state, one back to the 'Acceptance' state and the other to the 'Rejected' state. Name them consecutively 'Next supervisor' and 'Reject2'. Set their visibility to 'FALSE'.



On the action 'Next supervisor' enter the execution condition: '= IF(ISEMPTY(USER.B4), FALSE, TRUE)'.

This formula will ensure that only when a given person has a supervisor, the action will be performed (B4 is the cell with the supervisor's ID, and we check if this cell is empty).

Set this action to automatic and the execution time to '=ADDMINUTES(NOWUTC(),5)' (the ADDMINUTES formula adds minutes to the time in parentheses, and the NOWUTC formula returns the current UTC time).

Thanks to this formula, if the editor in this state doesn't perform any action, the action 'next supervisor' will execute itself after 5 minutes.


In this action 'On Enter' set two action steps:

- action step 'Add editors' or 'Set editors'; in editors enter '=user.B4'

- action step 'Set cell value', enter 'ID.A1' as the cell address, and value '=user.B4'


Thanks to all these settings for this action, if the person doesn't accept or reject the report in time, the report will be automatically sent to that person's supervisor. If this supervisor doesn't perform the action on time, the report will be sent to the supervisor of this supervisor and so on until app go to someone who doesn't have a supervisor.


Go to the action 'Reject2'. Set its execution condition '=ISEMPTY(USER.B4)', this action will be performed when the person doesn't have a supervisor.

Set this action to automatic, and the execution time to '=ADDMINUTES(NOWUTC(), 5)'.

Now, if the editor of the app is a person who doesn't have a supervisor, the expense report will be automatically rejected after 5 minutes.


5. Test

Check how the app works. Set yourself as a draft creator and save the app. Open the app and fill the data of an expense, then press the 'send to supervisor' button.


The app will now change its editor to your supervisor, and the supervisor will see a task in the Inbox.


After opening the app, the supervisor can accept or reject the report, but if he doesn't do so in 5 minutes, the app will automatically change its editor to supervisor of the supervisor.


And so over and over again, until someone performs an action or the app reaches a person without a supervisor, then the app will automatically go to the 'rejected' state.



Have more questions? Submit a request


Please sign in to leave a comment.
Powered by Zendesk