Migrating property from bool to specific value in string

Vote:
 

Hello,

I have a ContentType which contains a boolean to specify whether a background color should be set or not.

Now I would like to give the editors the option to choose the background color through a textfield.

Therefor I would like to migrate the boolean value from the old field to a specific hex color in the new field.


I've looked at MigrationStep but the two properties must be convertible between each other.

I don't like the option keeping the boolean field around on the ContentType, but hiding it for the editor.


Any suggestions would greatly be appreciated.

#209286
Nov 13, 2019 10:13
Vote:
 

In cases like this, I would create an admin tool that can be run after the deploy where I add the new property

In the tool:

  • Get all pages of the ContentType (using Find, FindPagesWithCriteria or IContentLoader).
  • For every page, set the value of textbox based on the value of the checkbox.
  • Save changes.

In the next deploy, remove the checkbox.

#209293
Edited, Nov 13, 2019 10:33
Vote:
 

Thanks for your suggestion. This will definitely do the job.

Is there any option to hook into any internal migration functionality in EpiServer?

Sort of like the MigrationStep, or the commerce IMigrationStep.

#209467
Nov 14, 2019 14:49
Vote:
 

Frankly I think you can use a scheduled job to do that...

#209468
Nov 14, 2019 14:56
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.