Escape XML Characters

mdidrikson
Kilo Contributor

Hello,

I have an XML SOAP request that gets sent out regularly to an external vendor. Our vendor is saying that we need to HTML encode our apostrophes in our messages. These show up in user last names such as O'Donnell.

I have tried to replace the apostrophe characters using the following code:



//FILTER OUT SPECIAL CHARACTERS FOR XML REQUEST
var apostrophe = "'";
defaultReporterFirstName = defaultReporterFirstName.replace(/'/g, apostrophe);
defaultReporterLastName = defaultReporterLastName.replace(/'/g, apostrophe);



The issue now is it appears that Service Now is HTML encoding the ampersand character at the beginning of the string, but this is breaking the HTML encoding for the apostrophe.

O'DonnellWeb Ticket

Is there a way I can HTML encode apostrophe characters in XML?

Thanks!

Mark Didrikson

6 REPLIES 6

Thanks John. Those don't seem to be working either. I'm going to see if we can filter out the apostrophe.

Thanks again.

Mark Didrikson


If you haven't already solved this, there was a new feature added to SOAP Message the middle of last year. Chris Maloy created a blog post about it earlier this week. It may apply to your situation:

http://community.service-now.com/blog/christophermaloy/using-setparameter-setstringparameter-setxmlparameter-when-using-soapmessage-c

We now have a function that allows you to insert a string or xml into a SOAP Message Parameter.