How can I host a plain HTML file on ServiceNow?

afranklin
Mega Contributor

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?

13 REPLIES 13

rgm276
Mega Guru

Have you tried using the CMS module and just posting static HTML pages to a new site ?


afranklin
Mega Contributor

Hi Robert - As far as I know, you can only add CMS-based UI Pages to ServiceNow CMS sites (and these include lots of extra ServiceNow markup). I don't know of any way to add plain HTML or other plain text files. If you know how to achieve this, please let me know.


I guess the real trick is 'absolutely' no mark-up, the static html page still has all the global ui scripts, etc..


but, you could open a new window from a UI page, and post the 'html' contents from another page into that?


for example:


if you created a STATIC HTML page (or other content block page), and pasted your HTML into that page, then you could do something like this on the UI page, and the new window will only have the contents of your other page on it, no markup



var NewWin=window.open('MyHTML','name','height=660,width=650,status=1');


var igr = new GlideRecord('content_block_static');


igr.addQuery('name','TestPage');


igr.query();


while (igr.next()) {


              NewWin.document.write('<html><head><title>' + igr.name + '</title></head>');


              NewWin.document.write(igr.static_content );


}


afranklin
Mega Contributor

Hi Robert,



Thanks for the idea, but that approach wouldn't really be useful for angular templates or creating service stubs (which would be called by things like other Javascript or test harnesses... so they would need to already exist as endpoints at the time of the request).



-- Akil


raghavanm
ServiceNow Employee
ServiceNow Employee

Hi


I am looking for the same. Is this possible from inside service now at all?


Or is it possible to do a apache mod_rewites to redirect in already hosted servicenow server from inside servicenow platform?


I have added my question on this in community as well


Serving a static HTML page from service now server