How can I host a plain HTML file on ServiceNow?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-12-2014 07:01 AM
Hi,
We'd like to serve plain vanilla HTML (or JSON, or other plain text) from the ServiceNow server with absolutely no ServiceNow specific markup being added. We'd like to do this for a number of reasons, including:
- serving AngularJS templates
- API stubs (for testing purposes)
- Development scenarios where the Jelly overhead and boilerplate SN markup is not needed or otherwise gets in the way
The closest we've been able to come so far is attaching a text document to a knowledge base article, but this hack isn't suitable because the process is extremely cumbersome and the resulting url is unwieldily, difficult to predict and manage, and would force us to hard-code the sys id of the Knowledge article into our Angular code. Any thoughts?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-12-2014 12:24 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-12-2014 02:06 PM
Hi Ravio - Thanks for pointing me to Jeff Benedict's AngularJS UI Framework. It is a very cool piece of work. I uploaded it to our instance and took a quick peek around. I'm not sure I grokked it completely in the 15 minutes I looked at it, but here is what I think it is doing:
- There is a table that tracks UI Macros as Angular Views
- There is a UI Page (ng-app-content.do) that knows how to unwrap and display a UI Macro if the macro is passed in the querystring
- I assume that when your Angular code then wants a templateUrl, it references the UI Page with the appropriate UI Macro as a querystring parameter
It's a very interesting approach that might address one of our concerns (serving AngularJS templates), but I don't think it helps us to post plain text files (which we need for API stubs and other scenarios). I'm assuming here that the UI Page that renders the macro would still have the ServiceNow boilerplate HTML. Let me know if I am missing something.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-12-2014 11:26 PM
There should be a way. One hack could be to define your own custom table which has a string field of length 4000 or more. Here in this field you can store your HTML. Now in your page where you want this HTML, on load using JavaScript or if possible using jelly code, query the content of this field and set the HTML. This is not a perfect solution and may have its own set of problems or may not work at all. Try to see if it works.
Edit: I found one more way to do this. I created a record of the HTML file in the attachment table and on load of the UI page where i wanted to include this HTML, i used the load method of jQuery. It looks like this:
$("#random_id").load("https://my-sn-instance.service-now.com/sys_attachment.do?sys_id=80d59dac2dfdfggdsa4f74b4da155d");
I prefer the first approach as in the second one if i have to make any change to the HTML, then i have to upload it again. Plus it deals with the attachment table so i am not sure on the performance.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-14-2014 08:50 AM
Hi Ravio - Yes, we considered this and it would work for HTML, but wouldn't help us for anything not interpreted by a browser rendering engine (JSON service stubs for example).