In this tutorial you will learn how you can manage app documents and execute action in them from another app, using action steps: "Distribute app from table" and "Execute actions in apps". You will see this on the example of two apps: in the first user will be able to fill and report their vacation request form and in the second supervisor will be able to send such form to the employee and accept or reject it.
1. Vacation plan app
Let's begin with creating app and naming it VACATION_PLAN. Open info tab and set two text input parameters: USER and YEAR.
Add two new spreadsheets and name them: PARAMS and DATA. In first you will use two cells, type in them formulas: =input(USER) and =input(YEAR). Here will be displayed input parameters passed during document creation.
In DATA section in the first column write: 'From', 'To' and 'Reason'. Set second column to editable and add validator 'Required' to each cell. Change type of first two cells to date. In this section user will be able to fill data about his vacation. The rest of rows and columns you can delete.
Create one more spreadsheet named CURRENT_STATE with only one cell, in which enter formula =currentstate(), which returns current state of app document. Change section visibility to false.
We want data from this app to appear in the app to manage vacations. For this purpose, you need to add aliases in cell properties. In spreadsheet DATA add aliases: From, To and Reason to proper cells in the second column. In section PARAMS add alias User to the first cell. The last alias State add to a single cell in spreadsheet CURRENT_STATE.
Create workflow actions widget and go to Workflow tab. Add four states: FILLING, SENT, ACCEPTED and REJECTED, for the last two mark end state checkbox. Connect them with actions: "Send to user", "Send", "Accept" and "Reject" as below.
On action "Send" set action step "Set editors", in parameters type identifier of the person responsible for managing vacations. For testing add your identifier there.
2. Distribute an app
Create a new app called VACATIONS_MANAGMENT. Add two-columns table and name it TO_DISTRIBUTE. Change its headers to Users and Year. Set both of them to editable and allow to add rows in options. Change type of the first column to dropdown list and set identifiers from sysuser list as items. Add aliases User and Year to proper columns.
Add Workflow actions section and go to workflow tab. Create action, which will go back to start state and name it "Send". On action add action step: "Distribute app from table". App, which we want to distribute is VACATION_PLAN. The table we've just created will have data for distribution and column with user will be the first column of that table. You can use alias by typing User in the parameter.
Add post workflow action step "Refresh page".
3. Execute actions in apps
Create another table in designer named VACATIONS with 5 columns. Change headers to: 'User', 'From', 'To' and 'Reason'. Bind it with app VACATION_PLAN and bind following columns with app aliases. Add condition in filter property, which will be adding to the table only these documents, which are in state SENT. Set the last column to editable and change its type to checkbox.
Add two buttons and change their captions to 'Accept' and 'Reject'. To both of them add actions: "Execute actions in app" and "Refresh page". As a section with apps give spreadsheet VACATIONS and as a filter - its column E. Set action name parameter to 'Accept' or 'Reject' depending on the button.
At the end you can take care of how your app looks - for example you can change button colors or add rich text sections, which will explain what user can do in app.
Add yourself as a draft creator in both apps and run app VACATIONS_MANAGMENT. Choose users to which you want to send a vacation form and for which year it will be filled. Click Send and chosen users should see a task in their inbox.
In app VACATION_PLAN user can fill necessary data and send form back for acceptation. You can see that in spreadsheet on the top, there are displayed data passed in input parameters.
Go back to VACATIONS_MANAGMENT. In the table you can see the data about sent vacation plan. In the last column you can mark as many forms as you want and accept or reject them from this app.