Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Chriztian Steinmeier 2798 posts 8788 karma points MVP 8x admin c-trib
    Mar 01, 2021 @ 11:06
    Chriztian Steinmeier
    0

    Where to convert data for new property editor when replacing another?

    Hi there,

    If I create a new property editor that should be allowed to replace an existing one, where should I handle the conversion of the old PE's data?

    E.g. if the exisiting editor is a TextString but the new one stores JSON - If I replace the existing datatype, my new PE likely chokes on the existing "simpler" string data...

    Is it enough to have the JS controller detect this somehow, or do I need to do something else at C# level too?

    /Chriztian

  • Dirk De Grave 4541 posts 6021 karma points MVP 3x admin c-trib
    Mar 01, 2021 @ 12:23
    Dirk De Grave
    101

    Doing it in a js controller "fixes" it for current content, but your published and non edited content still holds the "old" storage value... unless you have a property value converter that takes care of converting both old and new value to an object

    Could also use the editor model events that takes the model that is being sent to the editor, and do the conversion there (c# code). Again, same issue, other content not opened in editor yet (and not re-published) will still hold the "old" published value of that property

    Doing a migration could help, as you could loop all content having this property and change the value from text string to JSON.. yet, you'd have to republish all content (not ideal either)

    Or a property value converter which "examines" the format and creates the typed object from either the old or new value format (which is safe, but will leave you with some redundant/obsolete code as soon as all content has been published in the new format)

    Our approach mainly depends on the number of content... if number is low, a single migration to change the content value and publish is an option, otherwise we'd go with a property value converter that examines and emits the typed object to the value you're expecting in front-end (in that case we assume we have high numbers of content and we also almost sure not all content is going to be "touched" and re-published.

    -Dirk

  • Chriztian Steinmeier 2798 posts 8788 karma points MVP 8x admin c-trib
    Mar 01, 2021 @ 12:32
    Chriztian Steinmeier
    0

    Thanks Dirk!

    Hadn't really considered the ramifications fully, I can see — for me, I guess I can live with handling it in the JS controller and letting the PropertyValueConverter pass the value through as long as it's just a simple string.

    /Chriztian

Please Sign in or register to post replies

Write your reply to:

Draft