I have previously utilized PowerShell for item creation, modification, deletion, and presentation details in Sitecore.
ØRecently, I attempted to modify goals using PowerShell but was unable to find any relevant references.
ØFortunately, I received assistance from the Sitecore community and was ultimately able to complete the task.
ØIn order to read the assigned goals from the item, I created a form item with a "reference" field where I defined my actual ID.
ØFrom there, I was able to retrieve all the assigned goals from the item and apply my own logic as needed.
Please find my code here,
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | $successPageItem = Get-Item -Path "master:" -ID $UserItemId if (Test-Path -Path $successPageItem.Paths.Path) { # Get the assigned goals for the item using the Goals property $trackingField = $successPageItem.Fields["__Tracking"].Value Write-Host "trackingField Fields: "$trackingField , $successPageItem.Paths.Path if (![string]::IsNullOrEmpty($trackingField)) { $xml = New-Object System.Xml.XmlDocument $xml.LoadXml("$trackingField") $xmls = [xml]$xml # Select the first node using the SelectSingleNode method $firstNode = $xmls.SelectSingleNode("/*/*[1]") #form Json Object $jsonObject = @{ "referenceId" = $firstNode.id } |