Ok, I upgraded my site from 6 to 7. It's going fairly well now after fixing a lot of show stoppers! However, I just found out that MNTP didn't convert properly. In the old site, we stored the data as XML. In U7, it's stored as JSON (or looks like CSV to me, whatever)...
The problem is how do I take the existing XML data and convert it to the new format? The data is not available via Umbraco even because U6 stored the XML in the dataNText field and U7 stores it in the dataNVarchar field in the cmsPropertyData table.
Actually, it's 205 nodes... So I wrote a pure t-sql means of doing it... Not sure how to share this properly. First thing is create this function in your Umbraco database:
CREATE FUNCTION [dbo].[mntpConvert] (@mntpXml ntext)
RETURNS nvarchar(MAX)
AS BEGIN
-- Declare the return variable here
DECLARE @Result nvarchar(MAX)
DECLARE @list nvarchar(MAX)
DECLARE @xml XML
DECLARE @mntpData nvarchar(MAX)
SELECT @mntpData = CONVERT(nvarchar(500),@mntpXml)
SELECT @xml = CONVERT(xml, @mntpData)
SELECT @list = ISNULL( @list + ',', '' ) + x.y.value('.', 'VARCHAR(500)' )
FROM @xml.nodes('MultiNodePicker/nodeId') x(y)
-- Add the T-SQL statements to compute the return value here
SELECT @Result = CONVERT(nvarchar(MAX),@list)
-- Return the result of the function
RETURN @Result
END
Then you have to figure out how to query the cmsPropertyData and update the right records. I did it by finding my property's id and creating the appropriate update statement.
Here's my t-sql statement to do the above but OBVIOUSLY you'd want to change the propertyTypeId:
UPDATE cmsPropertyData
SET dataNvarchar = dbo.mntpConvert(dataNtext)
WHERE (propertytypeid = 138)
AND (DATALENGTH(dataNtext) <> 0)
AND (dataNtext IS NOT NULL)
CREATE FUNCTION [dbo].[mntpConvert]
(
-- Add the parameters for the function here
@mntpXml ntext
)
RETURNS nvarchar(MAX)
AS
BEGIN
-- Declare the return variable here
DECLARE @Result nvarchar(MAX)
DECLARE @list nvarchar(MAX)
DECLARE @xml XML
DECLARE @mntpData nvarchar(MAX)
SELECT @mntpData = CONVERT(nvarchar(500),@mntpXml)
SELECT @xml = CONVERT(xml, @mntpData)
SELECT @list = ISNULL( @list + ',', '' ) + x.y.value('.', 'VARCHAR(500)' )
FROM @xml.nodes('MultiNodePicker/nodeId') x(y)
-- Add the T-SQL statements to compute the return value here
SELECT @Result = CONVERT(nvarchar(MAX),@list)
-- Return the result of the function
RETURN @Result
END
GO
Umbraco 6 to 7: Multi Node Tree Picker Conversion
Ok, I upgraded my site from 6 to 7. It's going fairly well now after fixing a lot of show stoppers! However, I just found out that MNTP didn't convert properly. In the old site, we stored the data as XML. In U7, it's stored as JSON (or looks like CSV to me, whatever)...
The problem is how do I take the existing XML data and convert it to the new format? The data is not available via Umbraco even because U6 stored the XML in the dataNText field and U7 stores it in the dataNVarchar field in the cmsPropertyData table.
Hello,
I had the same problem. It was faster for me to manually change all the content than writing a converter. You could have a look PhoenixConverters.
Jeroen
Yeah, it just might be... Only talking about 25-30 nodes. I guess I can just do it in the database manually.
Actually, it's 205 nodes... So I wrote a pure t-sql means of doing it... Not sure how to share this properly. First thing is create this function in your Umbraco database:
Then you have to figure out how to query the cmsPropertyData and update the right records. I did it by finding my property's id and creating the appropriate update statement.
Here's my t-sql statement to do the above but OBVIOUSLY you'd want to change the propertyTypeId:
And for good measure, set the dataNtext column to null:
Here's the code formatted better...
is working on a reply...