Copied to clipboard

Flag this post as spam?

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


  • Nik Wahlberg 639 posts 1237 karma points MVP
    Nov 04, 2010 @ 22:08
    Nik Wahlberg
    0

    Media Picker w/ Preview after upgrade

    Hi All, I just upgraded one of our larger intranets to 4.5.2 and have found that the MEdia Picker with Preview doesn't work? It allows me to click the "Choose..." link and popup the tree, but when I click a media node in the tree nothing happens (it doesn't select anything)? I tried changing the data type to the standard media picker but then that wipes out all of my data for the fields. Has anyone successfully worked around this issue?

    Thanks for your help!

    -- Nik 

  • Nik Wahlberg 639 posts 1237 karma points MVP
    Nov 04, 2010 @ 22:12
    Nik Wahlberg
    0

    To add onto this...here's the FireBug error I get when the right-hand pane is first loaded:

    Type is not defined

    No error when trying to select the media. 

  • Matt Brailsford 4125 posts 22222 karma points MVP 9x c-trib
    Nov 05, 2010 @ 12:01
    Matt Brailsford
    0

    I'm not 100% (having not done it myself), but isn't Type.registerNamespace part of the MS Ajax toolkit? which I'm pretty sure the latest Umbraco doesn't have a dependency on, so look to me like something may not have been updated correctly.

    This is just my educated guess though, so could be wrong =)

    Matt

  • Nik Wahlberg 639 posts 1237 karma points MVP
    Nov 05, 2010 @ 12:09
    Nik Wahlberg
    0

    Hey Matt, thanks for chiming in. The error is occurring in the DependencyHandler.axd line 205. I have the Ajax Toolkit in the bin still since contour needs that as far as I know. What about updating the data type manually? This issue would go away if I was able to change the data type associated with this property. I'm guessing I have to put on my SQL hat for that... :) 

    Cheers!

  • Matt Brailsford 4125 posts 22222 karma points MVP 9x c-trib
    Nov 05, 2010 @ 12:12
    Matt Brailsford
    0

    Hey Nik,

    Is this a Contour thing? As, isn't the advanced media picker, just a checkbox in the prevalues for the regular media picker?

    Matt

  • Nik Wahlberg 639 posts 1237 karma points MVP
    Nov 05, 2010 @ 12:15
    Nik Wahlberg
    0

    It's not a Contour issue really, this happens in the content section when editing a page with the Media Picker w/ Preview data type. This package is not listed as compatible with 4.5.2 which I should surely have checked before upgrading (DOH!). So, in light of the issue I think the best approach is to revert back to the standard out-of-the-box media picker. Unless, of course, there's an update for the package floating around out there. 

    -- Nik

  • Matt Brailsford 4125 posts 22222 karma points MVP 9x c-trib
    Nov 05, 2010 @ 12:22
    Matt Brailsford
    0

    Ahhhhh, I see.

    If the advanced media picker saves the value as the same datatype as the regular media picker, you might be able to use the SQL statement out of my doc type extensions package for switching over data types:

    UPDATE   cmsPropertyData
    SET propertytypeid = {2}
    WHERE   id in (
        SELECT  pd.id
        FROM    cmsPropertyData as pd
            inner join umbracoNode as n on n.id = pd.contentNodeId
            inner join cmsContent as c on c.nodeId = n.id
        WHERE   n.nodeObjectType = 'C66BA18E-EAF3-4CFF-8A22-41B16D66A972' and
            c.contentType = {0} and 
            pd.propertytypeid = {1}
    )

    Where {0} is your doc type id, {1} is the property id, and {2} is the target property type id

    Don't forget to backup beforhand ;)

    Matt

  • Nik Wahlberg 639 posts 1237 karma points MVP
    Nov 05, 2010 @ 12:24
    Nik Wahlberg
    0

    right-on Matt! I knew you'd have something up your sleeve :) I'll give that a try. 

    -- Nik

  • Nik Wahlberg 639 posts 1237 karma points MVP
    Nov 05, 2010 @ 13:02
    Nik Wahlberg
    0

    Wow, this one is gonna suck. Unfortunetly, I won't be able to do what you are suggeting Matt. The [SQL] data types are different between the two custom types (one text and one int). So, I have to switch the data type for the content type in question, then go through the DB and move the value from dataNtext to dataInt in the cmsPropertyData column for ALL of the nodes. I'll have to write a stored proc or somethign to do this as we're talking about hundreds of nodes. 

    Oy! 

    -- Nik

  • Matt Brailsford 4125 posts 22222 karma points MVP 9x c-trib
    Nov 05, 2010 @ 13:18
    Matt Brailsford
    0

    Hey Nik.

    Are you needing to convert from text to int, or int to text? I'm pretty sure it could all be 1 statement.

    Matt

  • Nik Wahlberg 639 posts 1237 karma points MVP
    Nov 05, 2010 @ 13:21
    Nik Wahlberg
    0

    Hey Matt, from text to int. And I think you're right, one update should do it with the correct sub-selects....

  • Matt Brailsford 4125 posts 22222 karma points MVP 9x c-trib
    Nov 05, 2010 @ 13:29
    Matt Brailsford
    0

    Will this work?:

    UPDATE  cmsPropertyData
    SET     propertytypeid = {2},
    dataInt = CAST(cmsPropertyData.dataNtext AS INT)
    WHERE   id in (
            SELECT  pd.id
            FROM    cmsPropertyData as pd
                    inner join umbracoNode as n on n.id = pd.contentNodeId
                    inner join cmsContent as c on c.nodeId = n.id
            WHERE   n.nodeObjectType = 'C66BA18E-EAF3-4CFF-8A22-41B16D66A972' and
                    c.contentType = {0} and
                    pd.propertytypeid = {1}
    )

    Matt

  • Nik Wahlberg 639 posts 1237 karma points MVP
    Nov 05, 2010 @ 14:11
    Nik Wahlberg
    0

    Ok, so here it is. PROCEED WITH CAUTION AND BACKUP FIRST!

     

    • Update the data type for the property to media picker
    • 'Copy' over the values from the dataNtext field to the dataInt field for the given propertyTypeId
    update cmsPropertyData set dataInt=CAST(CONVERT(varchar(20),dataNtext) AS INT) where propertyTypeId={0}
    NOTE: You have to convert the Ntext to varchar before you can cast it as an Int. 
    • Clear the dataNtext value for the given propertyTypeId
     update cmsPropertyData set dataNtext=null where propertyTypeId={0}
    • Now we have to update ALL the versions of the page to hold the correct value in the dataInt field. This is hacky at best so be careful when running your query as it may update versions that you didn't want to touch. This is the only way I found the current version to be updated. If you have a mechanism to find the current version and ONLY update that, that would be ideal. 
    WITH contentNodeIds
    AS
    (
      SELECT DISTINCT(contentNodeId) as cNodeId,dataInt as cDataInt FROM cmsPropertyData WHERE propertyTypeId={0} and dataInt is not null
    ) UPDATE  cmsPropertyData SET dataInt=cDataInt FROM contentNodeIds where contentNodeId=contentNodeIds.cNodeId
    Hope this helps others too. 
    Thanks Matt for your suggestions too. 
    -- Nik

     

  • Matt Brailsford 4125 posts 22222 karma points MVP 9x c-trib
    Nov 05, 2010 @ 14:19
    Matt Brailsford
    0

    Hehe, nice work =)

    Glad you got it working.

    Matt

  • Siw Ørnhaug 130 posts 109 karma points
    Feb 05, 2011 @ 22:49
    Siw Ørnhaug
    0

    Just realized the version issue in one of my installations. Nik, did you do your upgrading directly in query editor in the Sql Server Management Studio?

    And does your instruction imply that when you change the data type property from media picker with preview to old fashion media picker, then the value of then Ntext data type is somehow retained and can be copied over? Is this because the change is applied with a new version generated? I ask because I truely don't know :-)

    It seems more secure to add a common media picker property and manually copy the media urls from old to new property, but of course that's a lot of work.

    Any of you know if the preview picker will be adapted to v. 4.5.2?

  • Nik Wahlberg 639 posts 1237 karma points MVP
    Feb 06, 2011 @ 14:03
    Nik Wahlberg
    0

    Hi Siw, it's a little more complicated than just switching the data type. As you can see, the columns for the Ntext and integer are stored in two separate columns. This means that you will have to migrate the value for the given propertyId by following the steps in my post above. I made these changes using SQL Management Studio. Let me know if you have any particular questions about the scripts, and again, be careful when making these database changes manually.

    Cheers,
    Nik

Please Sign in or register to post replies

Write your reply to:

Draft