Embed a report to an external site?

dinoseck
Kilo Explorer

Hey everyone,

 

I would like to know if it is possible to embed a report to an external site.

 

For example, instead of the end user having to create a report in ServiceNow, they would be able to view a live report from a Google site.

 

I have tried importing the table data from a report onto Google sheets as an =importHtml function, but it has not worked yet.

 

Thanks

11 REPLIES 11

Hi Dave,



We encounter a wrong rendering on Geneva patch 5 with embedded reports in external iframes.


Only list and single pivot report display data. All other types are not (only blank and print button is displayed).


It was indeed working under Eureka patch 11 version.



I thus found out your community thread and tried out your solution.


But it doesn't change a bit.



Did you encounter or hear about such behaviour ?


ServiceNow first level support also tried out to change the HTMLSanitizerConfig without more success.



Does anyone have a clue about what goes wrong ?



Thanks !


Ludovic,



We have recently assisted a client in upgrading from Eureka patch 11 to Geneva patch 5, and now the ability to embed ServiceNow reports in external websites will no longer work.



Ordinarily, the steps we go through to embed a ServiceNow report are...



* Set glide.set_x_frame_options property to false


* Embed a published ServiceNow report in an external website


* Report partially loads within an iframe on the external page, but is blank with only the print button displayed (top right)



We have also tested with the list widget in ServiceNow and this works correctly when embedded in an iframe within an external site, so the problem is limited to reports and not a security restriction. It seems the Javascript code in the ServiceNow report is trying to access the parent page (in this case our external website) but this is not allowed because the parent page is now not part of the same domain.



I've raised this as   INT2984968


Any luck Peter? We have a similar issue and raised an INT with SN. They were unable to help since they can't support 3rd party integrations.


Hi Blair,



We were informed by SN "The problem that made it impossible to have an instance embedded into an iframe was fixed in Helsinki Patch 3" although I have moved on to another customer and so haven't had the chance to test this. The consultant that was working on this account is away, so I'll check with him once he's back.



As an alternative, we were considering using ServiceNow web services with some of the popular open source charting libraries like D3. If you're interested, here's some code you're welcome to try out...



Go to Live Code Examples Powered by CodeMirror - NVD3 and try the bar chart, inserting the following code (which is basically a mash up of the code automatically generated by the ServiceNow REST API Explorer and the NVD3 examples. Please be aware you will need to set up a temporary CORS rule for the Aggregate API (GET) in ServiceNow to get this to work from the NVD3 site. Replace the instance, userID and password names below with your details



var requestBody = "";



var client=new XMLHttpRequest();


client.open("get","https://{YOUR INSTANCE}.service-now.com/api/now/stats/incident?sysparm_query=active%3Dtrue&sysparm_count=true&sysparm_group_by=priority&sysparm_display_value=true");



client.setRequestHeader('Accept','application/json');


client.setRequestHeader('Content-Type','application/json');



client.setRequestHeader('Authorization', 'Basic '+btoa('admin'+':'+'{YOUR PASSWORD}'));



client.onreadystatechange = function() {


  if(this.readyState = this.DONE) {


          showResults(this.response);


  }


};


client.send(requestBody);


                 


function showResults(json){  


  var incident = [


  {


      key: "Incidents by Priority",


      values: []


  }];


 


  var labelName, labelValue;


  var myData = JSON.parse(json);


  for (key in myData.result){


      labelName = myData.result[key].groupby_fields[0].value;


      labelValue = myData.result[key].stats.count;


      incident[0].values.push({label:labelName , value: labelValue});


      console.log(labelName + ' ' + labelValue);


  }



nv.addGraph(function() {


  var chart = nv.models.discreteBarChart()


      .x(function(d) { return d.label })


      .y(function(d) { return d.value })


      .staggerLabels(true)


      .tooltips(false)


      .showValues(true)



  d3.select('#chart svg')


      .datum(incident)


      .transition().duration(500)


      .call(chart) ;



  nv.utils.windowResize(chart.update);


      return chart;


  });


}


Hi Peter,



Web Services to generate D3 reports is actually how Explore Analytics works -- what we did is we packaged a Scripted Web Service into an update set that allows our solution to make live calls and take full advantage of GlideRecord and Glide Aggregate.



But it gives you a lot of power -- the ability to combine data from multiple tables in-memory on the fly, the ability to do calculations against the data, and to drill through to the list details behind it.



Here's an example of a report with ServiceNow data published outside of ServiceNow: Project - Animated Portfolio   -- easy to put in an iFrame.



You can also connect to other sources of data -- databases like Oracle or MySQL -- and combine them in a live report, like this one combining ServiceNow incidents with calls in a call system, live: Trend of Incidents and Call Volumes



It'll get you a lot of power and in-built functionality without you having to refine a lot of code, and with an app server to store trended data, uploaded spreadsheets, etc.