Last active
February 28, 2024 11:23
-
-
Save lars-erik/188c5a57bc893a9182c0ce5c28616a91 to your computer and use it in GitHub Desktop.
uSync Migrate Forms from V8 to V13
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
param( | |
$path | |
) | |
$files = Get-ChildItem -Path $path -File | |
$files | % { | |
$fileInfo = $_ | |
$doc = [xml](Get-Content $fileInfo.FullName) | |
$pageNode = $doc.DocumentElement.SelectSingleNode("Pages") | |
$origCData = $pageNode.FirstChild | |
$pages = [array]($origCData.InnerText | ConvertFrom-Json) | |
$results = $pages | % { | |
$page = $_ | |
$page.fieldSets | % { | |
$fieldSet = $_ | |
$fieldSet.containers | % { | |
$container = $_ | |
$container.fields | % { | |
$field = $_ | |
if ($field.parsedPrevalues.Length -gt 0) { | |
$field.preValues = $field.parsedPrevalues | |
} | |
$field.psobject.Properties.Remove("parsedPreValues") | |
} | |
} | |
} | |
} | |
$cdata = $doc.CreateCDataSection((ConvertTo-Json -depth 99 -inputobject $pages)) | |
$replaced = $pageNode.ReplaceChild($cdata, $origCData) | |
$doc.Save($fileInfo.FullName) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment