- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-20-2017 11:42 AM
Hi Guys,
I want to be able to put an RSS feed on my Service Portal. Has anyone been successful in creating one and helping me out in creating one? Ideally, I want to pull the feed from Krebs at the top of the service portal homepage.
Thanks,
David R
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-30-2017 06:59 AM
Hi David,
The reason the code you supplied doesn't work in Service Portal is because it uses an iframe that has a src path using plain http instead of https. It looks like you got the code from rssfeedwidget.com. But I don't believe they use https. So, even changing the url in the src attribute to use https more than likely won't get that to work either.
An alternative could be to use the RestMessageV2 and XMLDocument2 methods (and of course html and css to style it the way you want) to bring in the feed to your widget I have put together a very basic poc. It will bring in the Krebs on Security feed. It could also handle others too with a little adjustment. Most rss feeds are pretty much standard containing elements like channel, title, items, links etc.
Try putting this code within a widget and placing the widget on a page:
HTML:
<div class="panel panel-primary" ng-repeat="feed in c.data.feeds">
<div class="panel-heading">
<h4>${{{ feed.channel.title }}} - {{ feed.channel.description }}</h4>
</div>
<div>
<div class="list-group">
<div ng-repeat="item in feed.channel.items | limitTo: (offset - feed.channel.items.length) as filtered" class="list-group-item">
<a ng-href="{{item.link}}" target="_blank"><h3>{{ item.title }}</h3></a>
<h5>Author: {{ item['dc:creator'] }}</h5>
<div class="item-content">{{ item.description }}</div>
</div>
</div>
</div>
</div>
-------------------------------
CSS:
.item-content img {
width: 30%;
height: 30%;
display: block;
}
.feed-btn:first-of-type {
margin-left: 5px;
}
.feed-btn {
font-size: 9px;
}
----------------------
Server Script:
(function() {
try {
var r = new sn_ws.RESTMessageV2();
r.setHttpMethod('GET');
r.setEndpoint('https://krebsonsecurity.com/feed/');
var response = r.execute();
var responseBody = response.getBody();
data.httpStatus = response.getStatusCode();
var xmlDoc = new XMLDocument2();
xmlDoc.parseXML(responseBody);
data.feeds = [];
var feed = {};
feed.channel = {};
var channel = xmlDoc.getNode('//channel');
var channelIter = channel.getChildNodeIterator();
var items = [];
while(channelIter.hasNext()){
var node = channelIter.next();
var nodeName = node.getNodeName();
var nodeContent = node.getTextContent();
if(nodeName != '#text' && nodeName != 'item')
feed.channel[nodeName] = nodeContent;
if(nodeName == 'item'){
var item = {};
var category = '';
var itemIter = node.getChildNodeIterator();
while(itemIter.hasNext()){
var itemNode = itemIter.next();
var itemName = itemNode.getNodeName();
var itemContent = itemNode.getTextContent();
if(itemName != '#text' && itemName != 'category')
item[itemName] = itemContent;
if(itemName == 'category'){
if(category.length > 0)
category += ','+itemContent;
else
category += itemContent;
}
}
item.categories = category.split(",");
items.push(item)
}
feed.channel.items = items;
}
data.feeds.push(feed);
}
catch(ex) {
var message = ex.getMessage();
}
})();
This should give you a good starting point.
I hope that helps.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-21-2017 06:34 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-27-2017 02:56 PM
Thanks Harsh. It kind of, partially does. I'm diving into this with no knowledge of any coding languages so it's been quite a challenge compared to dragging and dropping widgets and containers into my Service Portal. I just don't know where to start in all of this. At most, I've just tried creating a new widget and copy and pasting codes I find on the web and previewing them but I've never successfully had a feed generate yet.
The code below, for example, creates a box for an RSS feed but I do not see the feed from Krebs going through at all.
<div id="widgetmain" style="text-align:left;overflow-y:auto;overflow-x:hidden;width:200px;background-color:#transparent; border:1px solid #333333;"><div id="rsswidget" style="height:500px;"><iframe src="http://us1.rssfeedwidget.com/getrss.php?time=1509141038612&x=https%3A//krebsonsecurity.com/feed/&w=2..." border="0" hspace="0" vspace="0" frameborder="no" marginwidth="0" marginheight="0" style="border:0; padding:0; margin:0; width:200px; height:500px;" id="rssOutput">Reading RSS Feed ...</iframe></div><div style="text-align:right;margin-bottom:0;border-top:1px solid #333333;" id="widgetbottom"><span style="font-size:70%"><a href="http://www.rssfeedwidget.com">rss feed widget</a> </span><br></div></div>
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-30-2017 06:59 AM
Hi David,
The reason the code you supplied doesn't work in Service Portal is because it uses an iframe that has a src path using plain http instead of https. It looks like you got the code from rssfeedwidget.com. But I don't believe they use https. So, even changing the url in the src attribute to use https more than likely won't get that to work either.
An alternative could be to use the RestMessageV2 and XMLDocument2 methods (and of course html and css to style it the way you want) to bring in the feed to your widget I have put together a very basic poc. It will bring in the Krebs on Security feed. It could also handle others too with a little adjustment. Most rss feeds are pretty much standard containing elements like channel, title, items, links etc.
Try putting this code within a widget and placing the widget on a page:
HTML:
<div class="panel panel-primary" ng-repeat="feed in c.data.feeds">
<div class="panel-heading">
<h4>${{{ feed.channel.title }}} - {{ feed.channel.description }}</h4>
</div>
<div>
<div class="list-group">
<div ng-repeat="item in feed.channel.items | limitTo: (offset - feed.channel.items.length) as filtered" class="list-group-item">
<a ng-href="{{item.link}}" target="_blank"><h3>{{ item.title }}</h3></a>
<h5>Author: {{ item['dc:creator'] }}</h5>
<div class="item-content">{{ item.description }}</div>
</div>
</div>
</div>
</div>
-------------------------------
CSS:
.item-content img {
width: 30%;
height: 30%;
display: block;
}
.feed-btn:first-of-type {
margin-left: 5px;
}
.feed-btn {
font-size: 9px;
}
----------------------
Server Script:
(function() {
try {
var r = new sn_ws.RESTMessageV2();
r.setHttpMethod('GET');
r.setEndpoint('https://krebsonsecurity.com/feed/');
var response = r.execute();
var responseBody = response.getBody();
data.httpStatus = response.getStatusCode();
var xmlDoc = new XMLDocument2();
xmlDoc.parseXML(responseBody);
data.feeds = [];
var feed = {};
feed.channel = {};
var channel = xmlDoc.getNode('//channel');
var channelIter = channel.getChildNodeIterator();
var items = [];
while(channelIter.hasNext()){
var node = channelIter.next();
var nodeName = node.getNodeName();
var nodeContent = node.getTextContent();
if(nodeName != '#text' && nodeName != 'item')
feed.channel[nodeName] = nodeContent;
if(nodeName == 'item'){
var item = {};
var category = '';
var itemIter = node.getChildNodeIterator();
while(itemIter.hasNext()){
var itemNode = itemIter.next();
var itemName = itemNode.getNodeName();
var itemContent = itemNode.getTextContent();
if(itemName != '#text' && itemName != 'category')
item[itemName] = itemContent;
if(itemName == 'category'){
if(category.length > 0)
category += ','+itemContent;
else
category += itemContent;
}
}
item.categories = category.split(",");
items.push(item)
}
feed.channel.items = items;
}
data.feeds.push(feed);
}
catch(ex) {
var message = ex.getMessage();
}
})();
This should give you a good starting point.
I hope that helps.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-31-2017 12:03 PM
Thank you so much Chris! This helps out so much and gives someone like me with zero language experience somewhere to start out with. Would you say that knowing/learning Javascript would be a place to start at in getting better with Service Now?