1

I would like with Sitecore Powershell to extract and display the ID(s) of the save action(s) that a WFFM has assigned. Those IDs in fact the ID of items from /sitecore/system/Modules/Web Forms for Marketers/Settings/Actions/Save Actions.

The field Save Actions from WFFM has the content saved as a xml and I would like to parse it.

Is there a way to do it in Sitecore Powershell ?

2 Answers 2

5

You can use the script below. Just set the root directory which holds your forms to $formsRoot variable.

The script:

  • gets all the forms from the root
  • gets ids of all the save actions in the system
  • creates a regex based on the ids of the actions
  • calls the regex on the value of the Save Actions field
$formsRoot = "/sitecore/content/MYSITE/WffmForms"
$forms = Get-Item master: -Query ($formsRoot + "//*[@@TemplateId='{FFB1DA32-2764-47DB-83B0-95B843546A7E}']");
$availableActionIds = Get-Item master: -Query "/sitecore/system/Modules/Web Forms for Marketers/Settings/Actions/Save Actions//*[@@TemplateId='{E01318E7-CEED-4EA4-B107-1B8FAC3A3DB8}']"| Select-Object -ExpandProperty ID;
$regex = [string]::Join("|", $availableActionIds).Replace("{", "\{").Replace("}", "\}");
$usedSaveActions = $forms | Select-Object -ExpandProperty "Save Actions" | Foreach-Object { return [System.Text.RegularExpressions.Regex]::Matches($_, $regex).Value; }
$usedSaveActions 
1
  • With some more small adjustments I was able to sued the script you suggested. Jun 13, 2019 at 15:00
1

You could just parse the field contents using the inbuilt PowerShell parsers:

[xml]$saveActions = $formItem[Sitecore.Form.Core.Configuration.FieldIDs.SaveActionsID]

That is now in a standard .net XmlDocument object, so you can use standard methods to parse that, like Select-Xml with XPath queries or:

$saveActions.node.attribute 

etc...

1
  • Not that useful in my context, @marek-musielak's suggested helped me better. Jun 13, 2019 at 15:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.