Moving metadata from text properties to Valuelist items

Sometimes a configuration change is made to elevate a property that is defined as text to become a valuelist.  In most cases the data in the text property need to be corrected to be consistent with the chosed valuelist items.  Using the power of SQL the text property can be analysed and updated. A temporary table with the adjusted valuelist items can be prepared.  When ready this data can be updated into the new valuelist using the standard external connector with Valuelists that point to the temporary table.  Once this is done the new valuelist items can be updated on the Class Table and refreshed into M-Files.  The last step is to remove the data from the class table.

Several special MFSQL procedures can be used in this process.

  1. spMFSyncroniseMetadata to update the metadata after the addition of the new valuelist property.

  2. spMFCreateTable to create the class table in question

  3. spMFupdateTable with updatemethod 2 to update the class table with the existing data.

  4. Create an additional table in SQL as a working table for aligning the textvalues with columns ClassTable_ID, TextpropertyValue, AdjustedTextValue, TargetValuelistItem_ID.

  5. Insert records from the class table to the working table.

  6. Use SQL to select and align the TextPropertyValue to the AdjustedTextValue.

  7. Configure Valuelist in M-Files with an external connection to the working table. Use a select distinct statement to import only the items from the AdjustedTextValue.

  8. use spMFSyncroniseSpecificmetadata with ValuelistItems to update the valuelistitems.

  9. use spMFCreateLookupView on the valuelist to create and easy to use lookup for the new valuelist

  10. use a select statement on the Class Table with joins to the working table and the new valuelistlookup and use an update statement to add the MFID of each valuelistitem to the Class Table. (include process_id = 1 in the update statement)

  11. use spMFupdateTable with update method 0 to update the data back into M-Files