Skip to content

Instantly share code, notes, and snippets.

@lars-erik
Last active February 28, 2024 11:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lars-erik/188c5a57bc893a9182c0ce5c28616a91 to your computer and use it in GitHub Desktop.
Save lars-erik/188c5a57bc893a9182c0ce5c28616a91 to your computer and use it in GitHub Desktop.
uSync Migrate Forms from V8 to V13
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