Skip to content

Instantly share code, notes, and snippets.

@enkelmedia
Last active April 28, 2021 08:38
Show Gist options
  • Save enkelmedia/5d6ee184cc3d404b524b51730537a9ff to your computer and use it in GitHub Desktop.
Save enkelmedia/5d6ee184cc3d404b524b51730537a9ff to your computer and use it in GitHub Desktop.
Multi Node Tree Picker-convert function.sql
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
@enkelmedia
Copy link
Author

enkelmedia commented Apr 28, 2021

Converts multi node tree picker from Umbraco 6 (xml) to Umbraco 7 (ids), note that this is the "legacy" format for MNTP in Umbraco 7 and will note work if you indent to upgrade further to Umbraco 8.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment