Frequently Asked Questions
Frequently Asked Questions
Changing property data type
Posted by Henri Huhtamäki (M-Files) on 27 September 2019 01:51 PM

1     Overview

When you have created a property and used it in objects, sometimes you want to change the property data type afterwards. Besides changing "Choose from list" to "Choose from list (multi-select)" or vice versa (and even in that, keep in mind that going from multi-select to single select will remove selected multiple values), changing the datatype can be problematic afterwards.

2     Solution / Workaround

NOTE: Always test everything in a safe test environment before attempting changes to production!

Changing datatype is problematic if there are existing objects using that property. If possible, the existing objects can be destroyed (NOTE: delete will not be enough) and then the property datatype can be changed.

If destroying the objects is not possible, for example there are a lot of them and they are in active use, you will need to create a new property with the desired data type, and then either manually or by code get the values from old property to this new property. Therefore, this is more of a workaround than a solution that can of course have other implications also when you are changing the entire property.

This can be done manually: For example, by creating a view that sorts objects by old property value, selecting all results in a virtual folder and selecting an equivalent value to new property for all selected objects.

If it seems like the manual approach is not practical, then you will need to utilize scripting or C# to accomplish this. For example, assign a temporary automatic value for the new property that selects old property value from same object and uses some mapping to decide correct value for new property. Then set this new property for all needed classes, recalculate values and finally do some searches to see if there still are objects with empty new property value.

Please refer to https://m-files.com/user-guide/latest/eng/Automatic_values.html for more information about automatic values and scripting.

M-Files developer portal has examples for C# VAF applications and other general instructions for coding https://developer.m-files.com/

(0 vote(s))
This article was helpful
This article was not helpful

Help Desk Software by Kayako case