Escaping special characters in XML

Dotychczas
Mega Guru

Hello, i need to escape special characters from string to safely insert them into XML document (for example "&" to "&amp" etc). Is there any build in function to do that? 

11 REPLIES 11

Hi,

So did you check this method which I mentioned

setStringParameter()

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

I think that this method is meant to be use in outbound rest message. I don't know how to implement it in rest step in flow designer.

Hi,

are you picking some field value which contains HTML string?

Can you share some more details for that REST Step you are using with some screenshot

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

in flow designer i created action which does two things: 1st it fetch incident record in script step and assigning it fields values to script outputs and 2nd in rest step in request body there is xml template and i just take fetched data and put it in correct xml tags. To be honest there is a lot of sensitive data in this rest step so screen shot is not a good idea. I tried to call script include 

  var xmlUtils = new XMLUtilJS();
gs.info(xmlUtils.escapeForXMLText("test&test"));

 

but I somehow can't get to escapeForXMLText method