Try our conversational search powered by Generative AI!

Migrating property from bool to specific value in string



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.

Nov 13, 2019 10:13

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.

Edited, Nov 13, 2019 10:32

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.

Nov 14, 2019 14:49

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

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.