XML CDATA save error with a Form

This forum can be browsed by the general public. Posting is limited to current SAPIEN license holders with active maintenance and does not offer a response time guarantee.
Forum rules
DO NOT POST LICENSE NUMBERS, ACTIVATION KEYS OR ANY OTHER LICENSING INFORMATION IN THIS FORUM.
Only the original author and our tech personnel can reply to a topic that is created in this forum. If you find a topic that relates to an issue you are having, please create a new topic and reference the other in your post.

Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
This topic is 10 years and 7 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
User avatar
DerekGary
Posts: 1
Last visit: Fri Jul 28, 2017 7:38 am

XML CDATA save error with a Form

Post by DerekGary »

When I try to save a form I get the following error:
Error during save: Cannot have ']]>' inside an XML CDATA block.

The code snippet is:
PowerShell Code
Double-click the code block to select all.
$rbParamString = ""
if ($rbParameters -ne $null) {
   
   # Format the param string from the Parameters hashtable
   $rbParamString = "<d:Parameters><![CDATA[<Data>"
   foreach ($p in $rbParameters.GetEnumerator())
   {
      #$rbParamString = -join ($rbParamString,"<Parameter><ID>{",$p.key,"}</ID><Value>",$p.value,"</Value></Parameter>")         
      $rbParamString = -join ($rbParamString,"<Parameter><ID>{",$p.key,"}</ID><Value>",$p.value,"</Value></Parameter>")
   }
   $rbParamString += "</Data>]]></d:Parameters>"
}

"@
I am using the MSDN code to trigger an Orchestrator Runbook with PowerShell: http://msdn.microsoft.com/en-us/library/hh921685.aspx

I am able to run the same code from a .ps1 script with PowerShell studio. So my current workaround is that I have a seperate .ps1 script that is called by the Form to run the needed code. Of course, I would prefer to have the entire code in the form.
User avatar
davidc
Posts: 5913
Last visit: Mon Jul 08, 2019 8:55 am
Been upvoted: 2 times

Re: XML CDATA save error with a Form

Post by davidc »

Unfortunately this is an XML issue. The Code is saved in a CDATA block which does not support any instance of "]]>" because it is a delimiter that signifies the end of the CDATA block.

The way around this is to split the "]]>" string.
PowerShell Code
Double-click the code block to select all.
$rbParamString += "</Data>]"
$rbParamString += "]></d:Parameters>"
David
David
SAPIEN Technologies, Inc.
This topic is 10 years and 7 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.