How to keep xml formatting in html notification?

peterraeves
Mega Guru

We are exchanging code with a 3rd party tool (EasyVista). To do so, we send them xml over SOAP. When something goes wrong, we want to send the xml content that was sent through email to verify the root-cause of the problem. To do so we created an event, containing the xml output, and added it to the notification. The problem is that the spacing goes haywire. How can we keep the correct formatting?

Code used to trigger the Event:

Image 3.png

Notification:

Image 2.png

Email body:

Image 4.png

Email preview:

Image 10.png

So how do I keep the correct spacing? What tag should I use? I tried <pre>, but it was removed when I saved the Notification 😕

4 REPLIES 4

Gurpreet07
Mega Sage

Hi Peter,



If you want the xml tags to be displayed in new line then you could use <br/>. Below link may help you to white list other tags for HTML editor.


http://wiki.servicenow.com/index.php?title=HTML_Sanitizer#gsc.tab=0


drbz
Mega Expert

Hi Peter,


did you try to create event without using GlideStringUtil.escapeHTML() method? I mean: gs.eventQueue(...., this.soap.getRequestBody()).



This should work if you change the content type field to Plain text only in Notification.


This would mess up ${URI_REF}, the bold and underlined text though.


Sigval Bergesen
Tera Contributor

Not 100% sure what you're after, but I'm guessing you want to azure that the xml string starts with a new line after every end tag? if so, just try something like this: yourXml.toString().replace(/<\//g, '\n<\/');