From d4fc879011a7656ac70ab5620a931c1c514c2d8d Mon Sep 17 00:00:00 2001 From: Alexander Zekelin <128831809+zekelinAlex@users.noreply.github.com> Date: Wed, 9 Sep 2026 14:14:28 +0200 Subject: [PATCH] feat: pp-form-subgrid single apply-scaffold post-action --- .../.template.config/template.json | 24 ++++------------ .../.template.scripts/ApplyScaffold.ps1 | 16 +++++++++++ .../.template.scripts/Cleanup.ps1 | 2 -- .../pp-form-subgrid/.template.scripts/add.ps1 | 28 ------------------- 4 files changed, 21 insertions(+), 49 deletions(-) create mode 100644 src/Dataverse/templates/pp-form-subgrid/.template.scripts/ApplyScaffold.ps1 delete mode 100644 src/Dataverse/templates/pp-form-subgrid/.template.scripts/Cleanup.ps1 delete mode 100644 src/Dataverse/templates/pp-form-subgrid/.template.scripts/add.ps1 diff --git a/src/Dataverse/templates/pp-form-subgrid/.template.config/template.json b/src/Dataverse/templates/pp-form-subgrid/.template.config/template.json index 4f6b9345..bbda08fd 100644 --- a/src/Dataverse/templates/pp-form-subgrid/.template.config/template.json +++ b/src/Dataverse/templates/pp-form-subgrid/.template.config/template.json @@ -7,7 +7,8 @@ "description": "Adds a subgrid to a form showing related entity records. Generates row > cell > control. Params: TargetEntityLogicalName, ViewId, RecordsPerPage, EnableQuickFind, EnableViewPicker, EnableChartPicker. Required: FormId, FormType(main/quick), EntityLogicalName, SubgridLabel.", "tags": { "language": "XML", - "type": "item" + "type": "item", + "componentType": "FormSubgrid" }, "sourceName": "subgridconfig", "preferNameDirectory": false, @@ -177,31 +178,16 @@ "actionId": "3A7C4B45-1F5D-4A30-959A-51B88E82B5D2", "args": { "executable": "pwsh", - "args": "-noprofile -executionpolicy bypass -File \"./.template.scripts/add.ps1\" ", + "args": "-noprofile -executionpolicy bypass -File \"./.template.scripts/ApplyScaffold.ps1\"", "redirectStandardOutput": "false" }, "manualInstructions": [ { - "text": "Adding new row to form" + "text": "Applying the subgrid scaffold via 'txc workspace component apply-scaffold'" } ], "continueOnError": false, - "description": "Adding new row to form" - }, - { - "actionId": "3A7C4B45-1F5D-4A30-959A-51B88E82B5D2", - "args": { - "executable": "pwsh", - "args": "-noprofile -executionpolicy bypass -File \"./.template.scripts/Cleanup.ps1\"", - "redirectStandardOutput": "false" - }, - "manualInstructions": [ - { - "text": "Removing Scripts" - } - ], - "continueOnError": false, - "description": "Removing Scripts" + "description": "Applying the subgrid scaffold via the TALXIS CLI" } ] } \ No newline at end of file diff --git a/src/Dataverse/templates/pp-form-subgrid/.template.scripts/ApplyScaffold.ps1 b/src/Dataverse/templates/pp-form-subgrid/.template.scripts/ApplyScaffold.ps1 new file mode 100644 index 00000000..69007581 --- /dev/null +++ b/src/Dataverse/templates/pp-form-subgrid/.template.scripts/ApplyScaffold.ps1 @@ -0,0 +1,16 @@ +$ErrorActionPreference = 'Stop' + +# Single interim post-action: all XML mutations run in-process inside the TALXIS CLI +# (txc workspace component apply-scaffold), backed by the platform metadata library. + +& txc workspace component apply-scaffold ` + --component-type 'FormSubgrid' ` + --solution-root '__solution-declarations-root__' ` + --file 'row=.template.temp/subgrid.xml' ` + --param 'entity=__entity-logical-name__' ` + --param 'form-type=__form-type__' ` + --param 'form-id=__form-id__' +if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE } + +Remove-Item .template.scripts -Recurse -Force +Remove-Item .template.temp -Recurse -Force diff --git a/src/Dataverse/templates/pp-form-subgrid/.template.scripts/Cleanup.ps1 b/src/Dataverse/templates/pp-form-subgrid/.template.scripts/Cleanup.ps1 deleted file mode 100644 index 97ba6e07..00000000 --- a/src/Dataverse/templates/pp-form-subgrid/.template.scripts/Cleanup.ps1 +++ /dev/null @@ -1,2 +0,0 @@ -Remove-Item .template.scripts -Recurse -Force -Remove-Item .template.temp -Recurse -Force \ No newline at end of file diff --git a/src/Dataverse/templates/pp-form-subgrid/.template.scripts/add.ps1 b/src/Dataverse/templates/pp-form-subgrid/.template.scripts/add.ps1 deleted file mode 100644 index d62d2954..00000000 --- a/src/Dataverse/templates/pp-form-subgrid/.template.scripts/add.ps1 +++ /dev/null @@ -1,28 +0,0 @@ -$entityXmlPath = (Resolve-Path './__solution-declarations-root__/Entities/__entity-logical-name__/FormXml/__form-type__/{__form-id__}.xml').Path -$rowPath = (Resolve-Path './.template.temp/subgrid.xml').Path - -[xml]$entityXml = Get-Content -Path $entityXmlPath -Raw - -$rowsNode = $entityXml.SelectSingleNode('//rows') -if (-not $rowsNode) { - Write-Error "Could not find rows node in the XML file." - exit 1 -} - -$rowRaw = Get-Content -Path $rowPath -Raw -$wrapped = "$rowRaw" -[xml]$newRowsXml = $wrapped - -foreach ($row in $newRowsXml.rows.ChildNodes) { - $imported = $entityXml.ImportNode($row, $true) - $rowsNode.AppendChild($imported) | Out-Null -} - -$settings = New-Object System.Xml.XmlWriterSettings -$settings.Indent = $true -$settings.NewLineHandling = [System.Xml.NewLineHandling]::None -$settings.OmitXmlDeclaration = $false - -$writer = [System.Xml.XmlWriter]::Create($entityXmlPath, $settings) -$entityXml.Save($writer) -$writer.Close() \ No newline at end of file