Calculate work durations
Tasks in Flowfinity are carried out by software robots, and used to automate routine data management activities in your workflow. Like most other features in Flowfinity, tasks are configured without code and do not require programming skills.
These activities are executed automatically once the user submits the form. You can set up tasks that execute operations for new and existing records in other apps, or update data within the current record.
For inspections and audits, the inspector needs to track the total time spent filling out the form for compliance and billing purposes. The total time spent is calculated by taking the time the form is submitted, and subtracting from it the time the form is opened on the device. The resulting total time will then be stored into a separate field, within the same record.
- Customize the application.
- In the Form section, add a new date/time field that is read-only (e.g. Started working at).
- Beside "Default value," enter "currentdatetime()" which is a pre-defined function in Flowfinity that captures the current date and time. This field will now capture the exact time the user opens the form, and store it as its default value.
- To make the field read-only, click on the dropdown under the "Editable" column, and select "No."
- Next, add a new field that is also read-only (e.g. Total time filling the form).
- From the "Type" dropdown, select Numeric field. This field will store the calculated value done by the task. In the "Default value" of the field, enter "0."
- To make the field read-only, click the checkmark under the "Editable" column, select "No."
- Next, go into the Operations section, and under the Tasks tab, add a new task.
- Give it a name (e.g. Calculate form filling in time), and add a design comment if you wish.
- Click on "Add action."
- Give it a name (e.g. Assign total time worked), and design comment. This action will calculate the total amount of time, and save the value into the field "Total time filling the form (mins)" created in step #6.
- Next, click on the Target tab, and select "Record." The "Record" target means that this task will apply updates to the current record that caused the submission.
- Click on the Fields tab, then "Add mapping." Under the Field dropdown, select the field "Total time filling the form." Under the Type dropdown, select "Formula."
- In the Value section, type the following formula:
- Click save.
- Then save the task.
- Next, specify when the task gets triggered. Click on the Operations tab.
- Edit the operation "Add New Record."
- Near the bottom under the Tasks section, click "Add task."
- Select the task you just created (e.g. Calculate form filling in time), and choose "Reject" from the dropdown. "Reject" means that this task must be completed successfully in order for the submission to be saved in the system, and removed from the device's pending list.
- Save operation, and publish the app.
- To see the results, create a new record and click submit. Once you view the record, you will see that the field "Started working on" will have a date/time value and the field "Total time filing in the form (mins)" will have the time in minutes.