Changing the data type of the SmartObject property by editing it directly in K2 Designer

  • 15 February 2022
  • 0 replies
  • 67 views

Userlevel 5
Badge +20
 

Changing the data type of the SmartObject property by editing it directly in K2 Designer

kbt155719

PRODUCT
K2 Five
K2 blackpearl
SEE ALSO
 
TAGS
K2 SmartObject Integration
This article was created in response to a support issue logged with K2. The content may include typographical errors and may be revised at any time without notice. This article is not considered official documentation for K2 software and is provided "as is" with no warranties.

Objective

In some scenarios you are unable to change the data type in the source LOB (Line of Business) system and may need to do that on the SmartObject level. It is possible but there are certain limitations which you need to keep in mind.

This approach is being used from time to time, for example, for SharePoint columns, as well as for other data sources where there is no possibility to change the data type on the source system side for some reason.

Example scenario: You have a SmartObject which is linked to an SAP Web Service and has a column "Cost Center" which is a text field, the data in SAP for this column is also stored as a text field. But the contents of this column is always a number with some leading zeros. If you change the data type of this property in the SmartObject itself from text to number it converts the data from string to number and removes the leading zeros.

Before You Begin

Be aware about the following limitations when using this approach:

Capability to change the data type for the SmartObject property is present in the product and supported as long as conversion of data is possible. If a text column contains only numbers (leading zeros are not important) then conversion will convert them to number dropping leading zeros, but it is enough to have some text value in one of the entries in that column to get an error.

Keep in mind that when you refresh the SmartObject it will revert the property to the type of data source. As a measure to safeguard against this you can consider designing advanced (manually created) SmartObjects which won't be impacted by "refresh" in the same way as a default SmartObject created from the data source automatically. More details on Advanced SmartObjects can be found in product documentation: K2 Five User Guide (current) - Advanced SmartObjects

A short note on why leading zeros gets removed when you convert text to number: this is logical for any conversion to Integer data type, which always treats leading zeros as insignificant for a number which represents quantity. In cases when leading zeros are playing any role in your data, this is by definition string/text data. Though having for instance, a fixed "cost center" length you can always reconstruct/re-add leading zeros back when you need help of expressions, for example. Data format will define what you can do with it, and how it will be processed (e.g. addition and subtraction works differently for numbers and strings).

How-to Steps

You can edit SmartObject properties and change its data type in K2 Designer.

Image


0 replies

Be the first to reply!

Reply