Last time, we have created forms for submitting and approving vacations requests. To be able to save a request, we need to create a process model which will take the data from the interface and save the request to the database. Also, we will create a confirmation screen which will give feedback to the user that the request is successfully saved.
To create a process model, we need to follow rules similar to those for creating an interface. First, we need to name the process and save it in the right folder. Next, we need to set the security, after which we will be presented with a process modeller.
Once we are in the process modeller, we are presented with the default process which has a start and end node. To be able to pass values in the process, first, we need to create some process variables. Navigate to “File” and click “Properties”. On the “Variables” tab, click “Add Variable” which will open another dialog. We need to name our variable and select a type that should be the same as the entity we had created earlier. In our case, we will name out variable “vacationRequest” which will be of type “VAD_vacation_approval”. It is important to select a variable to be a parameter and click “OK”. Since our interface for submitting a vacation request has a cancel button, we need another process variable with which we can verify if the user has cancelled the request.
To be able to save the request, we need a smart service that will write that data to the database. In the smart service search (left side of the modeller) we can search for the “Write to Data Store Entity“ smart service and drag and drop it onto the process activity connection line. We can configure the service by right-clicking and selecting “Properties”. On the “Data” tab, we need to define which value to save to which table. We can select a data store entity by searching for our application data store and selecting the right entity in the “Value” field. Also, we need to create another custom input which will be our previously created “vacationRequest” process variable and click “OK”.
If the user wants to discard the request by clicking “Cancel”, we do not want to save that request to the database. To redirect the process flow, we can use the XOR node. In the node properties, we can add a condition that will dictate which path to take. In our case, if the “cancel” variable is true, we will skip the write to the data store entity node and go straight to the end node. I the other hand, if the variable has a false value, we will save the request.
When the request is saved, we want a message to the user to be displayed to let him know that the action was completed successfully. For the confirmation screen, we can use a simple interface. This interface will not have a step-by-step guide. Try creating your own personalized confirmation screen or use our as a reference. If you get stuck, you can always check our previous guides on interfaces or check the materials.
To insert the confirmation screen into the process, we need to use “User Input Task“. In the node properties, on the “Forms” tab, we can select our confirmation screen interface. Also, we can add an exception timer that will skip that node after 5 minutes.
In the end, to be able to start the process from the interface, we can navigate to process properties and in the “Process Model Properties” we need to select our interface for creating a vacation request. Now just select “Save & Publish” from the “File” menu and our process is ready to use.
To be able to reference the process later in the application, we can create a constant which will represent a pointer to the process. We can do that by selecting “New->Constant” from the Appian designer. In the popup dialog, we need to select a constant name (all cap snake-case format) and the description. In the “Type” dropdown, we need to select a “Process Model” and as a value reference our previously created process.
Start the Process
If we go back to our homepage interface, there is a card that is created to start the vacation request process. By clicking on that card, we are presented with the “Select Link” option in the component configuration. We need to select “Start Process Link”. Click again on the created link and select our process constant in the “Process Model” field. After that, we can save the interface and test our application.
With this process, we have finished the first part of the vacation approval application. Next time we will create a process for request verification which will conclude this Appian guide series.