Authoring SmartObjects with code

You can use the SourceCode.SmartObject.Authoring and SourceCode.Framework assemblies to programmatically author and deploy SmartObjects using code. To help describe these, we have provided a sample Visual Studio project with source code that demonstrates how to:

  • Author a SmartObject
  • Deploy a SmartObject
  • Create Associations between SmartObjects

In the sample project, three SmartObjects are created programmatically and then published. Once the SmartObjects are published, associations are created between them. The three SmartObjects created are:

  • Employees
  • Regions
  • Departments

Each SmartObject is created with two properties, "ID" and "Name.". A fourth SmartObject is then created based on a combination of Employee and Region: this SmartObject links the GetList methods of the Employee and Region SmartObjects.

You can review the code in the sample project to learn how to perform these SmartObject Authoring tasks with code.

Sample Project
The following sample Visual Studio project demonstrates programmatically working with SmartObjects: K2Documentation.Samples.SmartObjects.Authoring. The sample project is provided for demonstration purposes only. It is not supported by the product and is not intended to be used as-is in production environments.

The sample project is a simple Windows application that creates and deploys the SmartObjects:

When finished, the following SmartObjects will appear in the Object Browser: