Part 1 of this tutorial will extend your knowledge of K2 SmartObjects and how you can define SmartObjects that interact with other systems. SmartObjects are essentially a "middle layer" or "connector" that allows consumers of data (such as forms and workflows) to interact with providers of data (such as SQL Databases, Active Directory or SharePoint, among others).
We will extend the Leave Request SmartObject by adding a field to store the approver comments. We will also create a SmartObject (and the underlying configuration necessary) to connect to a SQL database which will provide a list of Leave Types, which we will use in a later step to populate a drop-down list with data.
This step will demonstrate how you can add additional properties to existing SmartBox SmartObjects. We will add an Approver Comments property to the Leave Request SmartObject. (Later on, we will add this field to the Leave Request view).
In this step, we added a new property to the Leave Request SmartBox SmartObject to hold the approver's comments. Adding a new property to a SmartBox is reflected as soon as you Finish the designer, meaning the new property is ready for use in the Leave Request Item View that is based off of that SmartBox SmartObject.
In Step 2, we will create a connection called a "Service Instance" to an external SQL database using the SmartObject Service Tester tool, then generate a SmartObject for a specific table in that database (Leave Types) so that we can use the data later on in our Leave Request View.
Field Name | Setting | |
---|---|---|
A | Authentication Mode | Static |
B | User Name Password |
K2LearningUser
K2LearningPass |
C | On Different SQL Server | true |
D | Command Timeout | 90 |
E | Database Server | K2Learning
uh8ydarb4m.database.windows.net |
F | Use Native SQL Execution | false |
The ServiceObject tree contains the available Service Types ("connectors"), which in turn contain Service Instances (instances of the connectors that are configured to point to a particular data source). Recall that Service Types represent the various data sources (such as Active Directory, SQL, CRM) that K2 is capable of connecting to and interacting with. Service Instances are a single, specific connection to a Service Type data source such as a specific web service or a specific SQL database. We will be registering a SQL Server Service Instance during the steps in this exercise because the data we want to consume resides in a SQL database.
In the next step, we will register a new Service Instance of the SQL Server Service Type, then create a SmartObject based on that new Service Instance. This Service Instance will connect to an externally located SQL Server and will be the source of the Leave Type drop-down list values we will use on our form.
Field Name | Setting | |
---|---|---|
A | Authentication Mode | Static |
B | User Name Password |
K2LearningUser
K2LearningPass |
C | On Different SQL Server | true |
D | Command Timeout | 90 |
E | Database Server | K2Learning
uh8ydarb4m.database.windows.net |
F | Use Native SQL Execution | false |
Notice the new Leave Types Service Instance has been added under the SQL Server Service ServiceObject. From here, there are a number of options for creating a SmartObject from the Leave Types Service Instance. You can create a SmartObject in K2 Designer or with K2 Studio or K2 Visual Studio. And of course, you can create SmartObjects directly from within the SmartObject Service Tester, which is the approach we will take for this exercise.
The remaining default settings are fine, so click OK. Do not close the SmartObject Service Tester utility yet, because we will use it in the next step
We have now created a new SmartObject based on the SQL Server Service Type and connected it to the K2Learning database. What is significant here is that the K2Learning database is externally located, which demonstrates K2's ability to interact with a wide variety of data sources and other Line of Business systems.
Notice however, that K2 added the new SmartObject under a new category called Tables. In Step 3 we will return to our application in K2 Designer and move the generated [HumanResources].[LeaveType] SmartObject to the correct SmartObjects category, then rename it to the desired name, Leave Types.
In Step 2 we created a new Service Instance based on the SQL Server Service Type. This step demonstrated configuring a connection to a specific data source. With the new Service Instance in place, we then generated a SmartObject based on that Service Instance. In configuring the SmartObject, we were able to select a specific table in the target source, then configure it to reside within our Leave Request application.
Before we leave the SmartObject Service Tester, we will execute the List method on the Leave Types SmartObject to confirm the connection configuration is correct and the values stored in the Leave Type database table are being returned. We will then return to K2 Designer and rename the SmartObject, then move it from the Tables category into the SmartObjects category, then delete the Tables category.
In this step we confirmed the Service Instance configuration works by executing the SmartObject with the SmartObject Service Tester. The results returned are the values that are found in the external database's Leave Type table. We were also able to view the properties of the SmartObject which we will use in a later step. We then returned to K2 Designer and did some minor housekeeping by renaming the SmartObject, then moving it into the correct category and deleting the unnecessary Tables category.
This concludes the Data changes we will make for this new version of the Leave Request Approval application. In the next part we will edit the Views to add these data sources to the Form used in the application.
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
|