Sitefinity Field Migration
sitefinity | NET, CMS, Sitefinity, C#, Reflection | 2021-06-20
sitefinity | NET, CMS, Sitefinity, C#, Reflection | 2021-06-20
We have setup a content type with PostalCode in Number type.
Number in layman term means 0 ~ 9, however it is different in coding / Sitefinity; it means a decimal type in database column which is not logical to start with 0.
Therefore, when user create a new content, they could not enter Postal code start with 0 (we later founed out that some area of Singapore postal codes start with zero (0)).
Lastly, we have to find a workaround / alternative to fix our mistake in the beginning.
Firstly, backup the existing content. It is to create a backup for any migration failure and have incident recovery if the plan failed.
Create a new field in ShortText type named PostalCodes.
Rename the label of current PostalCode field to Postal Code (Old).
Run the field migration tool.
Check and verify the migrated data
Rearrange the dashboard navigation, front-end, listing and new/edit screen.
Lastly, delete the old PostalCode.
It is a very simple custom widget that consist of a input text box, a submit button and response message paragraph.
It is also set to allowed only Administrators to access the function.
To understand the context and make this works, we have study and decided to make use of c# Reflection technology.
The idea is to make use of C# Reflection technology to map the method name in a generic class. Then execute the function matched.
Lets key in some text and press submit, the result scenarios are below:
If the method name is mismatched.TADAAA! Migration will be executed and old PostalCode will be copied to new PostalCode within a few seconds.