Symptoms
When editing a SmartBox SmartObject in K2 Studio or K2 for Visual Studio and changing a property type (for example from integer to decimal), then the "Encrypted Property" will be disabled.
What happened in the meantime is that new data was added, unfortunately now there is both encrypted and unencrypted data in the SQL table (in the K2 database).
Diagnoses
When we tried to reproduce the issue, it seems that after making the first change, it does result in an error message when deploying. When making changes in K2 Studio or Visual Studio and deploying the SmartObject, K2 should automatically convert all the existing data in the SQL table to the new data type. However, when encryption was also switched off AND converting from Decimal to Integer, it resulted in the corruption of the data.
Resolution
We logged a bug that when changing a property type (from Integer to Decimal or vice versa for example), and those properties were encrypted, then the "Encrypt Property" checkbox switches off after the change:
TFS _659554 - K2 Studio: Encryption checkbox is not checked when data column type is changed
In order to resolve this, you'll have to do the following:
Option 1:
If you are able to get all the inserts and updates from your transaction log pertaining to the encrypted values that were added to the broken column, you can use them to repopulate the column with the old values after you fixed the column with K2 Studio.
You can fix the column by changing the property which is currently numeric to decimal encrypted and deploy the solution, once that's done, you have to change that property to numeric encrypted and deploy again. This will change the type of the column from bigInt back to varbind(55) which we use for the encrypted values. (If you get SQL deployment errors you need to go clean that column of old values and try again)
Option 2:
If you are going to manually update the column then all you have to do is use K2 Studio to deploy that property as a decimal encrypted type, then you at least have it as the type you tried to change it to.
The reason one has to change the property types back and forth between deployment is because we only update the column property type if a change in the Smart Object's property type was picked up during deployment, we don’t update the column type if only the encrypted check box option changed.
It’s also important to note that we currently do not support changing an encrypted property type to something else, even if it's encrypted numeric to encrypted decimal, the methods used for each differ.
After doing the above, it resolved the original issue, but resulted in the original data being lost.