This document contains the step-by-step instructions to build Version 1 (or the "basic" version) of the Leave Request Approval Application. If required, please refer to the Application Design topic for an overview of the Application.
For clarity, we will divide this tutorial into four parts: in Part 1, we introduce you to the Data component by creating a SmartBox SmartObject to store our submitted form content. In Part 2, we concentrate on the Forms component by creating the views and form necessary for our Application. In Part 3, we focus on the Workflow component by building a simple approval workflow and then editing the Forms for the additional workflow integration tweaks. In Part 4, we will test our Application.
Most applications require some kind of Data storage. In K2, this data storage usually refers to K2 SmartObjects. Part 1 of this tutorial will introduce you to K2 SmartObjects by creating a SmartBox SmartObject. SmartBox is K2-provided storage where K2 creates a dedicated table in the K2 database on SQL Server. For this scenario we will create a Leave Request SmartObject which will store the leave request information entered by the user.
This part should take around 15-20 minutes to complete.
The first step for creating our Leave Request Application is to add categories in K2 Designer that will house our forms, views and workflow. Categories can be thought of as folders. While this step is not required, it is a good practice to keep your K2 artifacts organized, especially as you begin to build larger applications.
On the left side of the screen is the Category Browser. This is where your K2 artifacts (forms, views, workflows, etc.) will be stored. The All Items category is the primary category for storing applications that you will build. First we are going to create a main category for our applications called K2 Learning. As you work through K2 tutorials, you can create categories under the K2 Learning category to keep your files organized.
If you are using an environment that is shared with other users, you may want to add your name to the folder name, so that your application does not conflict with other user's applications
Now we will create the categories specific to our Leave Request Application. Using the same steps as above, we'll add folders that will store the Forms, Views and SmartObjects of our application.
Your Category Browser should look like the image below.
In this step, we prepared the K2 Designer environment by creating categories (or folders) for our application (Leave Request) and application artifacts (Forms, SmartObjects, Views). We created a main category (K2 Learning) that we can use for future tutorials and for practice applications.
In this step we will create the single SmartObject required for the basic version of our application. This will be a SmartBox SmartObject and we will manually define the properties ("columns" or "fields") to store the Leave Request details. K2 provides default methods (Create, Get List, Save) for creating the new record when a Leave Request is submitted, listing previous Leave Requests and updating the record's status property. We will use these methods in later steps when configuring the Forms for the application.
Name | Type | Notes |
---|---|---|
ID | Autonumber | This field should be added already by default |
Leave Request Title | Text | |
Employee Name | Text | |
Employee Email | Text | |
Leave Start Date | Date | |
Leave End Date | Date | |
Leave Type | Text | |
Requester Comments | Memo | |
Request Status | Text | This field will be updated by the workflow as the leave request is submitted and then approved or rejected |
We don't need to adjust the category because the we started from the SmartObjects category to create this SmartObject. You can create SmartObjects a number of ways, then move them into a different category. The option to use this SmartObject in a Workflow will simply expose the SmartObject and its properties in the K2 Workflow Designer, which we will observe in Part 3.
On the Define Properties screen, notice that K2 has automatically created the ID property, which is the key identifier for each SmartObject record. In the next few steps, we will be adding the properties for our Leave Request SmartObject.
Name | Type | Notes |
---|---|---|
Leave Request Title | Text | |
Employee Name | Text | |
Employee Email | Text | |
Leave Start Date | Date | |
Leave End Date | Date | |
Leave Type | Text | |
Requester Comments | Memo | |
Request Status | Text | This field will be updated by the workflow as the leave request is submitted and then approved or rejected |
You have just created your first K2 SmartBox SmartObject. Taking a closer look at the SmartObject properties, you might recognize them as the future form fields we will use for our Leave Request Form (with the exception of the ID property, which is hidden). When a user submits a Leave Request, the form content will be saved to this SmartObject. As the workflow progresses, the Request Status property will be updated with the appropriate status value.
For this sample application we will be using K2 smartforms as the user interfaces to capture the Leave Request details and to approve the Leave Request. With our Data objects created in Part 1, we are ready to start on the Forms component of our application. The first step is to create an Item View.
Now that we have our SmartObject created, we can tell K2 to design a view based off of that SmartObject. K2 will create the view and assign the SmartObject properties as controls in the view, which you can then move around and edit as needed. The first view we will create is an Item View, or a view that contains the content for a single record. This view will become our Leave Request entry form and when submitted, will create one record back into the Leave Request SmartObject.
We do not need to make any edits to the Data Source, because we designed this view directly from the Leave Request SmartObject (the data source) itself.
When you select Create Labels and Controls, K2 will give us an option to select which fields we want on our view, plus a few other settings for the layout table. (The Create Layout Table Only option creates a blank table and you will need to drag and drop controls yourself. For this exercise we will use the Create Labels and Controls option).
Your new View should look similar to the image below. We've highlighted the sections you will use the most (Breadcrumb Bar, View Menu, Design Canvas, Toolbox, Properties Pane and Navigation Wizards/Save/Help) to help you with terminology if you are new to K2 Designer. As we move forward with the steps and exercises, you will become more familiar with the Designer layout and terms.
Now that we have the basic view designed, we'll add a few customizations that will make the view a little more user friendly. 99% of view and form design are preference and you will learn what works for your users and what doesn't as you build more applications. First, we'll adjust the width of the label column and second we'll adjust the width of the two date fields.
Notice the Employee Email Data Label. Where a label is a static control (it never changes), a data label is a control that cannot be changed by the user, but is dynamic in nature. The Employee Email value will change to reflect the user currently logged in. (This is actually a rule we will set in a later step.) Data labels can also be hidden to perform some type of function within the form or view.
Next, we'll change the Leave Type text box to a drop-down list and add some choices for our users to select. This will keep the Leave Types consistent as they are saved to the SmartBox.
We have one last adjustment to make to our view layout. We'll move the Create button to the right side of the view, which will make the view flow smoother for our users.
Your view should now look like the image below.
In this step, we created an Item View based on the Leave Request SmartObject. By designing the view directly from the SmartObject, K2 automatically created the view fields which we were able to include and /or display. We selected the Create button for our View. K2 creates all of the necessary rules and actions so that when the button is clicked, a new SmartBox SmartObject record is created in the associated Leave Request SmartObject. We also applied some minor formatting and we manually entered the values for our Leave Type drop-down list.
The next view we are going to create will be a List View. List views contain the content from multiple records. The purpose of this view is to output all of the previous leave requests from the current user. This will be especially helpful to the approving manager, to assess how much leave this employee has requested, or for the requesting user to see the status of their prior leave requests.
Call this method when the form loads. Because we have designed this list view based off of a SmartObject, K2 by default will retrieve all content from the SmartObject when the view is loaded. This is not what we want. We want only the records that pertain to the current user, not all of the records. That is why we turn off this option. In a later step, we will configure an Action to retrieve any records for the current user only.
There are no other changes to the layout editor, so click OK when ready. Click Finish (Navigation Wizard - lower right corner) to save and exit from this view.
In this step we created a basic List View based off of the Leave Request SmartObject. We will use this view to retrieve previous leave request records for the current user.
Recall that a form is the main container for views and additional controls. In this next step, we will create a Form and add the two Views created in the previous steps. We will then apply a new theme to change the Form's look and feel.
You should now be on the Form Designer screen. The Form Designer has a design canvas and many of the same toolbars and panes as the View Designer.
The last step in creating our form will be to customize the look and feel by changing the default theme to the Lithium theme. K2 has a number of predefined themes that you can apply to your forms, or you can create your own as you advance in your K2 knowledge. Lithium is K2's latest theme and is compatible with mobile devices, so it is a good option if your users will be using devices like tablets and phones to access SmartForms. It is possible to extend the standard list of themes with custom themes, for example if your organization has a particular color scheme.
(If you have trouble seeing the Theme property, it's quite possible that a view is currently selected.)
Once the Lithium theme is applied, the form style should change to something like the below
Views and forms are not available to your users until you have checked them in. This essentially "publishes" the artifacts to the K2 server. If you make a change to a view or form, you must check it in before those changes are evident to your users.
In this step, we created a new form and then added our Item View and List View to the Form canvas. We gave our form a complete make-over by simply changing the theme.
In Part 3 we will create the Leave Request Workflow, which will incorporate the Data and Forms components created in Parts 1 and 2. The workflow will contain a User Task (the manager making a decision on the request) and System Tasks (updating the status property in the Leave Request SmartObject).
In this step, we will create a new workflow in K2 Workflow Designer. We will associate the workflow with the Leave Request Form and assign workflow rights to all domain users.
Click Next when you are ready.
What is the Folio? The Folio is a free-text field that is commonly used so that it is easier to distinguish between instances of the same workflow. Think of it as a human-readable “unique reference” for a workflow. The Folio does not have to be unique and does not have to have a value, but assigning some unique value to the process Folio will make things easier for people who may need to report on or work with the workflow. You can assign a value to the process Folio when the workflow is started and update the Folio at any time during the workflow.
Often, Folios are made up of a combination of fields such as the customer name and the order number and the start date. You can also use the Folio as a variable throughout your workflow. For example, you might append the Folio to the first line in an email such as: RE: [Folio], where [Folio] is replaced at runtime with the value assigned to the Folio field.
As an example, you might assign the form originator’s name as the Folio to distinguish one instance of that workflow from another. The image below represents a Process Instance report for the Leave Request Workflow based on the requester’s name. Notice how the Folio column has a unique value for each record (or workflow instance) listed.
At this point, we have configured the basic settings for our Leave Request Workflow. We still need to assign permissions however, and to do that, we need to access the advanced workflow settings.
If you do not assign permissions, your users will see an error when they submit the form. The Start setting allows users to start the workflow and the View setting allows users to view the workflow reporting information.
Click Finish
Now that we have our workflow settings complete, we can move on to adding steps to the workflow. The first event we are going to add will be a System Event using the SmartObject Event wizard. Here, we will set the Request Status property to indicate the Leave Request has been submitted.
In this step we created the Leave Request Workflow and configured it to use the Leave Request Form. We assigned Workflow Rights, or permissions, to all domain users so that they can start the workflow and view workflow progress. We added a SmartObject Save event, which will update the status property to indicate the form has been submitted.
In this step, we will add a User Task which will be the approval decision assigned to the workflow originator’s manager.
We will not customize the task notification email for this application, so click Finish. Your screen should look like the image below.
In Step 7, we added a User Task and assigned it to the workflow originator's manager. We added two actions (Approved and Rejected). K2 automatically generated outcome lines for each of the actions we added. We can have many actions, but we need to have at least one. By checking the option to notify the participant of a worklist item, the manager will receive an email indicating they have a task, with a link to open the form and action the task.
Step 8 continues with the addition of two System Tasks that will update the Request Status property in the Leave Request SmartObject depending on the decision made by the approving manager. K2 Designer makes reusing events very simple by allowing you to copy and paste existing events. With a few minor adjustments, your new events are ready to go!
Notice that K2 copied the Save event as well as the Continue outcome line. In the next few steps, we will adjust each new event so that they are consistent with their outcome, then we'll add a Placeholder event to the last two empty event boxes. A Placeholder simply completes an outcome line without adding a formal event. This allows you to deploy and test your workflow without receiving errors of missing events.
Save your work.
In this step, we reused the Save event for the Approved and Rejected outcomes. By copying and pasting the event, we could take advantage of configurations already in place (the ID property already mapped). Copying an event will also copy its associated outcome, so we added Placeholders into each of the new event boxes that were created. We cannot deploy or test our application with empty event boxes, so the Placeholders tell K2 that the event boxes are empty by design.
Next we will deploy our workflow. Deploying a workflow publishes the workflow to the K2 server which then allows it to be exposed to the forms configured for that workflow. If you make changes to your workflow, you must redeploy it before the changes are published to the K2 server.
Now that the workflow has been deployed, we can go back into our Forms and tweak them a little based on where in the workflow the Form is being used (think of this as the "State" of the Form). For example, when the Form is used in the Manager Approval step, we want to load the Previous Leave Requests for the user who requested the leave. Or when the Forms is used to Start the workflow, we want to populate some of the controls on the Form with the current user's information.
In step 10, we will edit the Form for the Start Workflow state. We will add an action that retrieves the current user's previous leave requests found in the Leave Request SmartObject. These records will populate our List View. The second step will be to configure K2 to automatically populate the Employee Name and Employee Email fields on the form with the current user's details.
First, we want to populate the Leave Request List View. Recall that this is the view we created to output a list of all leave requests previously submitted for the requester. To do this, we want to execute (call) a SmartObject method (Get List) for the list view.
Now click the (configure) link. There are two primary sections to the editor that opens. First, we need to tell K2 which user's records we want (this is the input value) and second, we need to tell K2 which SmartObject properties we want to return (these are the output values).
Next, we want to display the current user's name and email on the Leave Request Item View. K2 will automatically populate these fields based on who is logged in. These values will then be saved to the Leave Request SmartObject when the form is submitted, along with the leave request details. This step is simply a matter of transferring system values to the Item View fields.
In this step, we edited the Form Initializing rule on the Leave Request Workflow (Default) state, so that the current user's previous leave requests will populate the Leave Request List View when the form loads when capturing a new Leave Request. We also configured the system values for the Display Name and Email (again, for the current user) to populate their corresponding fields on the Item View.
In this step, we will edit a rule so that the approving manager sees the originator's leave requests. We will hide the Create button, since the approving manager doesn't need to create a record. K2 will automatically add a third view to the form for the approving manager, which will contain our actions (Approved/Rejected) and a submit button.
As a reminder, states are used to control the behavior of a Form based on how it is being used. In the previous step, we edited the Leave Request Workflow (Default) state, which represents the point at the very beginning of the workflow. We edited the Form Initialize rule because we wanted to configure the user interface at the very beginning of the process. Now, we want to configure the user interface for the approving manager. In our application, this is called the Workflow Task state.
First, we want to configure an action so that the originator's previous leave request are loaded. Then, we will hide the Create button for the manager, as it is not needed.
In the Context Browser expand the Leave Request Item View node, then the Leave Request SmartObject. Drag the Employee Email into the Employee Email input property.
In this final step to creating our basic Leave Request Application, we configured two actions for the Workflow Task state. This is the state that represents the approving manager user interface. First, we configured an action that will retrieve the originator's previous leave requests. We also hid the Create Button from the manager, as it is not needed.
Now it's time to test our basic Leave Request Application.
We will submit two Leave Request Forms. Using the link found in one of the task notification emails, we will open the worklist item and action it (mark it as "Approved" or "Rejected"). We will then open the Leave Request Forms again to confirm that the previous two leave request records are appearing in the List View with the correct status value. (One record should say "Submitted" and one should say "Approved" or "Rejected".)
Now we need to open the approving manager's Outlook and confirm the task notification emails were received. Then we will action one of the tasks. If you are working on a K2-provided virtual environment (VM), you are likely logged in as Denallix Administrator. Administrator's manager is Jonno, so we'll open Jonno's Outlook. (If you are building this application in your own environment, you will need to access the appropriate Outlook account of the Manager for the user that submitted the leave request or whatever user you selected for the Manager Approval task when you designed the workflow)
Jonno's Outlook will begin to open. This can take a minute or two when using a Virtual Machine environment. If you see a message about synchronizing CRM data, continue to wait. If you see a message about licensing, close to continue.
Confirm that the Leave Request details are correct (A below) and then confirm that both form submissions show up in the Previous Leave Requests view with the Request Status as Submitted. (B below)
In this step, we tested our Leave Request Application by submitting two forms using the Runtime URL. The Runtime URL is the "user" link that allows your users to access and submit your forms. (Note: depending on your K2 environment setup, this link would probably only be available to internal users in your organization but there are ways of exposing SmartForms to the outside world) We confirmed the task notification emails were sent and after actioning one of the worklist items, we confirmed the Request Status property was updated appropriately in the Leave Request SmartObject.
The exercises in the Leave Request (Basic) Application are meant to provide an introduction to building K2 Applications and the K2 components of an Application: Data, Forms and Workflows. By completing the five parts, you should have a basic understanding of how data, forms and workflows integrate with each and how rules can be implemented to provide dynamic functionality to your user interface (for example, auto-populating form fields with the current user details). Key to these exercises are the following:
Data
Forms
Workflows
Video | Links | Learn | Support |
No videos found for this article K2 on YouTube
No Additional links found for this article
No self-learning content for this article Try some scenarios...
No relevant support links available for this article
|