Advanced SmartObjects
Advanced SmartObjects are used when you want to integrate with some system, create composite SmartObjects that combine data from different systems, or if you want finer control over the naming, properties and methods for an existing SmartObject. To create an advanced SmartObject, select the Advanced SmartObject option when creating the SmartObject, as shown in the image below.
Creating an advanced SmartObject allows you more options than when creating a basic, SmartBox SmartObject. You can add properties and methods from other data sources, and control which properties and methods are available on the SmartObject.
- For an example demonstrating how to configure a service instance and manually create SmartObjects, see this short video: Configuring a Service Instance and manually creating SmartObjects
- For an example demonstrating how to configure a service instance and automatically generate SmartObjects for you, see this short video: Configuring a Service Instance and auto-generating SmartObjects
- See How To: Configure the Picker control to display a list of employees using a security provider for an example of creating an advanced SmartObject and using the URM service with a Picker control to list employees in an organization
- How To: Create a SmartObject to connect to a REST service
- How To: Create a SmartObject to connect to a web service
- How To: Create an advanced SmartObject to connect to a SQL Database
- See How To: Create a composite SmartObject for an example of combining data from a SmartBox SmartObject and Active Directory (AD).
- See How to: retrieve user details in a form and a workflow for an example of creating and using a SmartObject to retrieve user information from a URM-based SmartObject.
- See How To: Use the Oracle Broker in a K2 Environment for an example of creating a SmartObject based on an Oracle service object.
Consider the diagram below, showing a basic, SmartBox SmartObject. Because it is a SmartBox SmartObject, the data for the SmartObjects is stored in a table in a database (called SmartBox), maintained by K2. The person who created the SmartObject did not have to tell K2 where the data comes from, all they did was create a basic SmartObject and define the properties (ID, Name, Email) that are contained in the SmartObject. Behind the scenes, K2 automatically created the necessary storage areas for this basic SmartObject, and automatically created the methods for the SmartObject (e.g. Create, Read and Update).
A basic SmartBox SmartObject
Now suppose that you already have a Microsoft SQL database that stores employee data, and you want to expose that data as a SmartObject. You can do this by using the K2 Management site to create a Service Instance that exposes the target SQL database to K2, and then creating an Advanced SmartObject and mapping the properties and methods in this SmartObject to the columns and operations available in the SQL database. Consider the diagram below. Here, we have a Employee table in a SQL database with some columns. We created a Service Instance that points to this SQL database, and K2 generated a Employee Service object that maps to the columns and operations available in the SQL database table. You can then create a Employee SmartObject in Advanced mode, and configure the properties and methods of this SmartObject to point to the generated Service object. When a form or a workflow calls the Employee SmartObject at runtime, K2 will then retrieve the values from the SQL database. To learn more about the architecture and terminology used in SmartObjects, please see the topic SmartObject terminology and architecture.
An advanced SmartObject
Advanced SmartObjects use service object definitions, created when you register a new instance of a service type, to query and update data. When you register a service instance of a specific service type, K2 will discover the available objects in the target system and create service objects for the data in the target system. Once the service objects exist, you can create an advanced SmartObject to expose that system as a SmartObject. K2 provides service types for various technologies such as Microsoft SQL, Oracle, Active Directory, REST services, OData services, Microsoft Exchange, cloud storage, and more. For more information see Service Types and the Product Compatibility, Integration, and Support matrix.
When designing advanced SmartObjects, you can also combine data from different systems into one Composite SmartObjects. Composite SmartObjects combine data and methods from various sources into one logical entity. This allows you to create business entities (such as Employee, Customer, Order) that query and update data from the different systems where the data is stored through a single object. For details see How To: Create a composite SmartObject.
Consider the diagram below. Here, we still have a SQL database that stores employee data, but we want to add data that resides in Active Directory to our Employee SmartObject. To do this, you create an advanced SmartObject, and then define a method for the SmartObject that points to methods in the Service Objects. In this example, the Read operation might call the Employee.Read method to retrieve data from the SQL database and the User.Read method to retrieve data from Active Directory, and then combine this data before returning the SmartObject to the calling application. Generally, to create a composite SmartObject, you would need some common property to be able to 'join' or 'find' data in each system. In this example, we can use the common Email property to 'join' the data retrieved from SQL with the data retrieved from Active Directory.
A composite SmartObject
To create an advanced SmartObject, select the Advanced SmartObject option when creating the SmartObject as shown in the image below.
If you had previously created a SmartBox-based SmartObject and want to change it to an advanced SmartObject, edit the existing SmartObject, click the General tab, then select the Advanced SmartObject option. This switches the existing SmartObject to an advanced mode SmartObject.
When editing a SmartObject in advanced mode, you can configure the properties or methods of a SmartObject and map them to Service Objects methods and properties.