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.

See the following resources for more information:

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, and more. For more information see a Service Instance and the Product Compatibility, Integration, and Support matrix.

When designing advanced SmartObjects, you can also combine data from different systems into one composite SmartObject. 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