Using SmartObjects to integrate with other systems and technologies
You can use SmartObjects to integrate K2 with other systems and technologies. For example, you may want to expose employee data stored in a Microsoft SQL database as a SmartObject, so that employee data can easily be used by designers when they build their forms, Reports and workflows.
Before you begin to build SmartObjects that integrate with other systems, you may want to review SmartObject terminology and architecture to understand how K2 integrates with other systems through SmartObjects, as well as the terms used when you work with SmartObjects.
Creating a SmartObject for another system or technology
Creating a SmartObject that integrates K2 with another system is best approached with a sequence of five steps.
1. Determine the Service Type
The first step in creating a SmartObject that connects to another system is to determine the appropriate service type for the system that you want to connect to (for example, a SQL database, an Active Directory domain or a Web Service). K2 comes with a number of standard K2 Service Types that will allow you to connect to a certain technology. Service types are usually specific to the provider technology. For example, to connect to an SQL database, use the SQL broker, to connect to a REST web service, use the REST service broker.
2. Register a Service Instance
If there is not already an existing Service Instance for the service broker configured for the provider you want to use, use the Service Types screen in the K2 Management Site to register a new Service Instance of the Service Type to connect to the data source. Depending on the service type, you may need to provide different configuration settings to set up the Service Instance. As part of the service instance registration process, K2 will discover the underlying provider and automatically generate Service Objects for the provider. Depending on the size of the provider store, this process may take a few minutes to complete.
To register a service instance, you will need to consider the following settings and provide appropriate values, depending on your use case and environment.
- Authentication
- Determines which credentials K2 will use to connect to the service at runtime
- Authentication also affects the credentials that K2 will use to query the data provider and discover the available entities
- Configuration settings
- Configuration settings are specific to the type of broker and will be different depending on what kind of technology you are connecting to
- Optional: auto-generate SmartObjects
3. Create SmartObjects
If you did not auto-generate SmartObjects while registering the Service Instance, you can use tools like K2 Designer to manually create a SmartObject and map that SmartObject to service object methods and properties. To do so, you will need to use the Advanced SmartObjects approach to build the SmartObject,
4. Test the SmartObjects
Once the SmartObject has been deployed, you can use the Management Site to test the SmartObject, or create a quick workflow, form or report to test the SmartObject and that it behaves as expected.
5. Use SmartObjects in forms and workflows
Now that your SmartObject is ready, you can start using it in your forms, workflows, reports or the K2 APIs. Remember that you may need to maintain the SmartObject if the data structure in the provider changes. For example, if a new column is added to the underlying SQL table, you will have to refresh the Service Instance to discover this change, and then edit the SmartObject to map the new column to a new property of the SmartObject, and redeploy the SmartObject. Then you can adjust your SmartForms/workflows/reports to utilize this new property.