Copied to clipboard

Flag this post as spam?

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


  • Rob Watkins 369 posts 701 karma points
    Oct 05, 2017 @ 09:51
    Rob Watkins
    0

    Upgrading 4.11 to 7.7.2 - MultiNodePicker

    I am upgrading an old 4.11 site, which uses the uComponents MultiNodePicker.

    This does not carry across to the new version, so I selected the Umbraco.MultiNodeTreePicker (Obsolete) thinking that this would be the replacement.

    Trouble is, it does not load the existing stored values into content.

    I get the following error in the log:

    2017-10-05 10:47:51,929 [P36824/D54/T78] WARN 
    Umbraco.Web.Models.Mapping.PreValueDisplayResolver - Could not find
    persisted pre-value for field values
    

    The old values are persisted as XML, of course - does the new picker not load that? Is there any way around this - I have a lot of fields to migrate!

  • Simon Dingley 1470 posts 3427 karma points c-trib
    Oct 05, 2017 @ 10:44
    Simon Dingley
    0

    I've done a fair few upgrades now and I make use of PhoenixConvertors for which I've had to develop some of my own but the project does have a Legacy MNTP to MNTP convertor out of the box which is what you will likely need to migrate the legacy data.

    https://github.com/imulus/PhoenixConverters

  • Rob Watkins 369 posts 701 karma points
    Oct 05, 2017 @ 11:32
    Rob Watkins
    100

    Hi Simon, thanks for that - I created a manual process in the end - her it is for anyone interested:

    First, get affected nodes as XML:

    select '<r id="' + cast(id as nvarchar(10)) + '">' + cast(dataNtext as nvarchar(max)) + '</r>' 
    from cmsPropertyData where dataNtext like '%MultiNodePicker%'
    

    Wrap the above in <root></root>.

    Use an XSL tool to transform to an update statement:

        <xsl:stylesheet version="1.0"
        xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
        >
        <xsl:output method="text" indent="yes" />
    
        <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
            IDENTITY
            - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
        <xsl:template match="root">
        <root><xsl:apply-templates /></root>
        </xsl:template>
    
        <xsl:template match="r">
        update cmsPropertyData set dataNvarchar= '<xsl:apply-templates select="MultiNodePicker/nodeId" />' where id = <xsl:value-of select="@id" />
        </xsl:template>
    
        <xsl:template match="nodeId">
        <xsl:value-of select="." />
        <xsl:if test="count(following-sibling::nodeId) &gt; 0">,</xsl:if>
        </xsl:template>
    
        </xsl:stylesheet>
    

    This should give you something like:

        update cmsPropertyData set dataNvarchar= '3026' where id = 50233
        update cmsPropertyData set dataNvarchar= '3027,3028' where id = 50234
    

    NOTE 1: You may have to run the again for the cmsPropertyData.dataNvarchar field to get them all. NOTE 2: This is for the OBSOLETE node picker, but no reason you couldn't modify the SQL in the transform to get the guid for the new style storage.

  • Rob Watkins 369 posts 701 karma points
    Oct 05, 2017 @ 12:04
    Rob Watkins
    0

    The above technique also works with the old MultiUrlPicker - use this transform to convert link info into plain html links separated by line breaks - modify for plain text / markdown or whatever.

        <xsl:stylesheet version="1.0"
        xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
        >
        <xsl:output method="text" indent="yes" />
    
        <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
            IDENTITY
            - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
        <xsl:template match="root">
        <root><xsl:apply-templates /></root>
        </xsl:template>
    
        <xsl:template match="r">
        update cmsPropertyData set dataNtext= <xsl:apply-templates select="multi-url-picker" /> where id = <xsl:value-of select="@id" />
        </xsl:template>
    
        <xsl:template match="multi-url-picker">
        <xsl:if test="count(url-picker) &lt;= 0">
        <xsl:text>''</xsl:text>
        </xsl:if>
         <xsl:apply-templates select="url-picker" />
        </xsl:template>
    
        <xsl:template match="url-picker">
        <xsl:text><![CDATA['<a href="]]></xsl:text>
        <xsl:value-of select="url" />
        <xsl:text>" title="</xsl:text>
        <xsl:value-of select="link-title"  />
        <xsl:text><![CDATA[">]]></xsl:text>
        <xsl:value-of select="link-title"  />
        <xsl:text><![CDATA[</a>']]></xsl:text>
        <xsl:if test="count(following-sibling::url-picker) &gt; 0"><xsl:text>+ CHAR(13) + CHAR(10) + </xsl:text></xsl:if>
        </xsl:template>
    
        </xsl:stylesheet>
    

    NOTE: This only gets the link url and title as that's all I need; you can get target etc easily enough though.

Please Sign in or register to post replies

Write your reply to:

Draft