SmartBox SmartObjects
SmartObjects allow you to create data objects by specifying properties and associations using the K2 SmartBox service. You automatically get the five standard methods available on all SmartObjects you create this way.
The SmartBox Service service type is used for SmartBox-based SmartObjects. SmartBox is a K2-managed SQL schema in the K2 database and is used for storing SmartObject data when there is no existing line-of-business system to store the data. SmartObjects you create using the K2 Designer typically use the SmartBox provider unless you change the SmartObject to use data from another service type. See SmartBox Service for more information.
The Properties tab displays all the properties and their configuration settings such as Type and Key. The ID autonumber property is added by default to all new SmartObjects. You can edit this property and change it, for example to EmpID, or delete it. A SmartObject requires at least one Key property.
To add a new property, click Add. The Add Properties page opens. You can capture the details of the property here and select a property type.
Action | Description |
---|---|
Add | Creates a line where you can add the property name |
Edit | Edits the property information |
Remove | Removes the property |
Remove All | Removes all properties |
Move Up | Changes the position of the property selected with the property above it |
Move Down | Changes the position of the property selected with the property below it |
Name | The name of the property |
Description | The description of the property |
Type | The type of the property |
Key | The Key property identifies the property as unique, which ensures that the value of the property is always unique and no two records can contain the same data for this property. A SmartObject requires at least one Key property |
Required | Creates a required property when new records are added to the SmartObject, for example from a view or a form |
Unique | SQL specification that sets a requirement for this field to be unique |
The following property types are available when you create a SmartObject property:
Type | What it is |
---|---|
AutoGUID | Similar to Autonumber, AutoGUID is an identity type where a GUID is auto-generated when a record is created |
Autonumber | When a new record is created in the SmartObject, an index number is automatically generated |
Date | Allows you to set a property to display data in a date format |
Date Time | Allows you to set a property to display data in a date and time format |
Decimal | Allows you to enter decimal numbers in the SmartObject property |
File | Stores a file of supported types |
GUID | Global Unique Identifier |
Hyperlink | Stores the property data as a hyperlink. See Use the SmartObject hyperlink property to navigate to a URL for an example of using this property to navigate to a URL. |
Image | Stores an image of supported types. See How To: Attach Images in Emails for an example of attaching an image to an email. |
Memo | Large String |
Multivalue | Use multivalue data types to store multiple values in one SmartObject property. When you use service objects that have multivalue properties, such as the Active Directory service object, the values are translated to the XML schema provided below . If the format cannot be translated, the data type is not stored. An example of the expected schema is: <collection> <object> <fields> <field> <value>2</value> </field> <field> <value>4</value> </field> <field> <value>6</value> </field> </fields> </object> </collection> The multivalue data type is typically used with a Check Box List control in views. This reads and updates the values from the multivalue property. The values shown in the Check Box List can be either static values or SmartObject list results. |
Number | Allows you to input numerical values |
Text | Stores ANSI standard text characters |
Time | Allows you to set a property to display the data in a time format. |
Yes/No | Boolean type property |
Use the information below to determine where and when to use the following data types:
- DateTime - Allows you to specify a Coordinated Universal Time (UTC) that shows the time in the local timezone.
- DateTime (with timezone) - Allows you to use a UTC time that does not vary based on the local timezone, see configuring a time zone.
- Date - You can use this for a timezone-invariant date (no time).
- Time - You can use this for a timezone-invariant time (no date).
You can configure settings that further define the SmartObject properties. The types of settings depend on the property type you edit. This means that not all settings are available on all property types. Follow the steps below to configure the property settings.
Some of the additional property settings such as Maximum Size, Time Precision, and Constant Size only apply to SmartBox SmartObjects. Other line of business systems might not support the property settings as described in the table below. When a SmartObject is a SmartBox object, several property settings may only be changed when there is no data in the SmartBox SmartObject. If there is data you may be blocked when trying to save the changes. If that is the case, you must export data from the SmartObject, delete that data, update the SmartObject, and then import the data again.
- From the K2 Designer, select the SmartObject and click Edit.
- Select the property and click Edit.
- The Edit Property page shows.
- Autonumber (auto-indexed)
- Autoguid (auto-indexed)
- File
- Image
- Memo
- Multivalue
- The Key setting is selected (auto-indexed)
- The Unique setting is selected (auto-indexed)
- The Encrypt setting is selected
- 1 - Minimum value
- 100 - Default value
- 200 - Maximum value
- 0 - Minimum value
- 0 - Default value
- 7 - Maximum value
- 0 - Minimum value
- 2 - Default value
- 12 - Maximum value
- Click OK to save changes made to the properties.
The following table describes the available property settings:
Setting | Applies to | Description | How to Use |
---|---|---|---|
Name | All | The name of the SmartObject property. | Type to add or edit the value |
Description | All | The description of the SmartObject property. | Type to add or edit the value |
Type | All | The data type of the property. | To change the format, select a value from the drop down. |
Key | All | Use this to set the property as a unique identifier for the SmartObject. | Check the check box to select property as the unique identifier. |
SmartBox | Advanced SmartObject | Use this to create the property in a SmartBox table. | Check the check box to create the property in a SmartBox table. |
Required | All | Use this to specify if the property requires a value before the record can be saved. | Check the check box if the property requires a value. |
Unique | All | Use this to specify that the property can only contain unique values. | Check the check box to require only unique values for this property. |
Indexed | All | Use this to improve performance when you filter a SmartBox SmartObject property or associate it with other SmartObjects. You cannot use this setting on the following property types:
This setting is disabled when: | Check the check box to create an index for this property. |
Constant Size | Text | Use this to specify if a text field has a constant size. Check this check box if the information entered into this field has a fixed number of characters, such as a social security number.
| Check the check box. |
Maximum Size | Text | Use this to specify the maximum length of text you enter into the property. For example, if you type 100 into this field, the most characters stored in the database are 100. You can increase the maximum size value even if your SmartObject contains data.
An error occurs when you decrease the maximum size value when there is data in the SmartObject. | Type a value between 1 and 200 into the field. |
Time Precision | Time | Use this to specify the time format for the property. You can specify the number of decimal places added after the seconds (hh:mm:ss.sss). Examples If you select the time precision as 0 and your input data is 08:27:34.1866667 the value shows as 08:27:34. If you select the time precision as 1 and your input data is 08:27:34.1866667 the value shows as 08:27:34.1. If you select the time precision as 7 and your input data is 08:27:34.7600000 the value shows as 08:27:34.7600000. If you select the time precision as 7 and your input data is 02:22:22.12345678 (8 decimal places) the value show as 02:22:22.1234568. Notice how only 7 decimal place show and rounding was applied. You cannot type a value greater than 7. It is possible to use the broker to set a value greater than 7, but this results in a SQL error. You cannot change the value if there is already data in the SmartObject.
| Type a value between 0 and 7 into the field. |
Decimal places | Decimal | Use this to specify the decimal format for the property. The value specifies the number of decimal places to be added. An error occurs when you type a value greater than 12. You also receive an error when you decrease the decimal value if there is already data in the SmartObject and the value is smaller than the value being set. Example: The value in the database is .3333333 (decimal places of 7) and you decrease the value to 2. You can, however, increase the number of decimal spaces as this does not represent potential data loss. For example, if the value in the database is .33 (decimal places of 2) and you increase the value to 5.
| |
Encrypt Property | Decimal, Number, Text | Use this to encrypt the SmartObject data when it is written to the database. This means, even if a nefarious user obtains copies of your database files (.mdf, .ndf, .ldf or backup files) they can not access or view any of the data unless they also have a copy of the encryption key or a security certificate. Example: You create a SmartBox HR application with a Social Security Number property and mark this property as encrypted. Should another business user connect to SQL directly, they will not see unencrypted SSNs. Ensure that your SmartObject does not contain any data or a Data Access Policy before setting the Encrypt property. | Check the check box to encrypt the property. |
When you work with Advanced SmartObjects, make sure to check the SmartBox check box to enable the additional settings.
Property types or better known as data types are automatically validated upon executing the CREATE or SAVE method on a SmartObject. For example, if you try to CREATE a new record for a SmartObject property called Mobile with a data type of type [Number], but with a value that is of type [Text], a server side message displays stating that validation has failed.
The Methods tab only displays when creating an Advanced SmartObject.
The Methods tab is not visible when creating a standard SmartObject as default methods are automatically created for this type of SmartObject. The methods created by default are:
- Create - Creates records
- Save - Saves records
- Load - Uploads records
- Delete - Deletes records
- Get List - Lists records
These methods are available in the K2 Object Browser under Environment > SmartObject Server for use in K2 workflows. If you want to choose multiple SmartObject services, or to add/delete SmartObject methods, you must create an Advanced SmartObject or edit the SmartObject and change the type to Advanced SmartObject.