November Happy Hour will be moved to Thursday December 5th.
November Happy Hour will be moved to Thursday December 5th.
I think you'll need to create a new property and migrate the data.
You could have a look at MigrationStep but I'm not sure it can be used here...
Thomas is right in suggesting the use of MigrationStep, I've used it to create and mutate content items on site start up. The great part is that they execute once per environment. You'd have to use the IContent Repository to mutate your old field values onto your new fields and you'd have to iterate over all of your content items with some form of recursive lookup. I would advise then when you save a content item within a MigrationStep that you use the following save command:
contentRepository.Save(writeablePage, SaveAction.Patch, AccessLevel.NoAccess);
SaveAction.Patch will bypass any validation errors when updating the content. During a migration step you won't want validation errors to prevent you from converting the field. The AccessLevel.NoAccess prevents the save event from needing a user with specific privileges to be the person triggering the save event.
An alternative tactic would be to retain both fields and use a method to access them. If the IList<ContentReference> field is null or empty then fall back to the old ContentReference. In the interim you could specify that the old version of the field should not be editable by decorating it with:
[ScaffoldColumn(false)]
I think it is strange because it seems to only be the case for some data types. I changed a property of type int to string and it worked perfectly fine in the cms
Hi Laurent,
It will be down to the compatability of the fields when swapping out the types. Int to String isn't really a biggy. However ContentReference to IList<ContentReference> can be much more complicated.
IList<ContentReference> goes into the [tblContentProperty].[LongString] field as such:
["606f485d-5c54-480c-9b42-695a125f6734","6264447a-71bb-4801-8f03-6442ea067793"]
ContentReference goes into [tblContentProperty].[LinkGuid] as such
14e8403c-321a-4840-bca7-bb161e69dd45
In this scenario a transformation has to take place as the value won't translate, one is essentially a string array while the other is a UID.
Hi,
we are trying to change property type from ContentReference to IList<ContentReference> is there any way to do that in-place or do we need to create a new field and migrate the data?