Adding Video to Knowledge Articles

/, Knowledge Management, Service Portal/Adding Video to Knowledge Articles

Adding Video to Knowledge Articles

Support for video in knowledge articles seems like it should be pretty straightforward but unfortunately history has proven otherwise. Standards have been shifting over time and the methods for displaying video in HTML have had varying levels of support depending on the browser. By default ServiceNow only supports out-of-date plugin methods of embedding video. While video support can certainly stand for some updating by ServiceNow, there are a few steps that can be taken now to allow for functional video use.

This method enables video to be used across the board in the HTML editor so it can be added wherever it is needed. It uses the HTML5 video tag and does require the user to be at least a little familiar with HTML but at this point that is difficult to avoid.


The first thing to do is whitelist the video and source tags in the HTMLSanitizerConfig script include. To do this replace this:

HTML_WHITELIST : {
  globalAttributes: {
    attribute:[],
    attributeValuePattern:{}
  },
},

With this:

HTML_WHITELIST : {
  globalAttributes: {
    attribute:[],
    attributeValuePattern:{}
  },
  video: {
    attribute:["width", "height", "controls", "autoplay", "loop", "muted", "poster", "preload", "src"],
    attributeValuePattern:{}
  },
  source: {
    attribute:["type", "src", "media", "sizes"],
    attributeValuePattern:{}
  }
},

To embed a video, open the article (or other record with an HTML field) and upload the video file.

Get the Sys ID of the attachment. An easy way that end users can do this is by clicking the “View” link next to the attachments.

Then copy the Sys ID from the URL.

Next click the “<>” icon to view the HTML source.

Paste in the following code, changing the value for the Sys ID parameter to that of the attachment.

<video controls="controls" width="100%" height="150">
  <source src="/sys_attachment.do?sys_id=[Sys ID of the attachment goes here]&amp;view=true" type="video/mp4" />
</video>

NOTE: mp4 video looks to have the best support across browsers at the time of writing. The video tag has a number of options that allow for tailoring the content to the browser, device size, and other things as needed.

By | 2017-03-14T05:37:23+00:00 March 14th, 2017|Categories: Content management, Knowledge Management, Service Portal|Tags: |10 Comments

About the Author:

Having led the way on numerous implementations of ServiceNow starting in 2008, James has experience across the board including traditional areas of ITSM like Incident, Problem, Service Catalog, and Configuration Management as well as Content Management System (CMS) sites Service Portal, HR, and more. He has education background in IT and has held a variety of positions giving him a broad perspective on how things work and the ability to handle the details while still looking at the big picture.

10 Comments

  1. Jonathan Bledsoe March 15, 2017 at 7:30 am - Reply

    Thanks for the info James, a couple of comments/questions. First it appears when we attach a video to a KB article it doesn’t work well on mobile(specifically iOS). Second performance seems to be pretty slow when hosting videos as attachments, even when my video is under 5MB it takes 10+ seconds for the video to buffer before playing. Any other suggestions as where to upload files within ServiceNow?

    • James Farrer March 15, 2017 at 9:07 am - Reply

      There are a lot of ins and outs of video across devices. iOS is pretty picky in what it will allow for video. I don’t have an immediate solution for you, but in the research I’ve done there are a couple possible fixes that can be made by optimizing the video for iOS and/or web. As I have time I’ll try and make some progress in that approach.

      From the performance perspective some the same optimizations for the web could help, but it depends on ServiceNow’s support. Basically, some videos are set up to be able to stream well and some operate under the assumption that you’ll have the whole file available as when it’s stored on your computer. If you want to understand some of the details involved, here is an article that explains some of it pretty well.

      As an alternative, most frequently, I’ve seen people host their video on YouTube so they don’t have to worry about those details. Instead of whitelisting the video and source tags, you’d need to whitelist the iframe tag. There are pros and cons to going this way but it’s certainly a lot simpler. The biggest potential downside I’ve heard is around security and the potential for someone to put in an iframe to malicious content. Generally the HTML fields are limited to folks that are part of your organization and for most organizations this hasn’t been a significant concern but for a few it has been. The advantage is that YouTube takes care of all the messy video support issues and it just works.

      Here’s the snippet that can be added to the HTMLSanitizerConfig script include to whitelist the iframe tag:

      iframe: {
          attribute:["align", "frameborder", "height", "longdesc", "marginheight", "marginwidth", "name", "sandbox", "scrolling", "src", "srcdoc", "width"],
          attributeValuePattern:{}
      }
  2. Bill Collins March 16, 2017 at 10:21 am - Reply

    As I recall, I only had to make the HTMLSanitizerConfig change. I did it sometime ago and haven’t heard any complaints from my customers. Bill

  3. Paul Curwen March 16, 2017 at 10:57 am - Reply

    Nice article, and it’s something I’ve come across again and again as the HTML Sanitizer just strips out any video links until you either switch it off for the KB description field, or set your White List correctly.

    Generally the preferred solution has been YouTube hosting if your organizations information Security team will allow it. If you do place your videos on YouTube, remember to set your privacy setting for the videos and (stating the obvious) don’t show any personally identifiable or business confidential information (anonymizing your data before recording your video can take some time) and also wipe out your URL text on the video.

    You will also need to configure some of the settings for the video on YouTube.

    Ensure you have Selected ‘Unlisted’ under the Basic Info tab to stop anyone stumbling across your video, and under the Advanced Tab, under Distribution Options ensure ‘Allow Embedding’ is checked so that you can put it in your KB article. It’s also probably best to untick ‘Allow Comments’, the ‘Users can view ratings for this video’ and ‘Allow viewers to contribute translated titles, descriptions, and subtitles/CC’ options.

    Using YouTube works seamlessly. Just put the link into your KB article and your are good to go. The video will start immediately once played (depending on your internet link).

    YouTube Security info can be found here: https://support.google.com/youtube/answer/157177

    • James Farrer March 16, 2017 at 11:15 am - Reply

      Thanks, those are definitely good steps to consider.

  4. Terryio July 20, 2017 at 2:05 am - Reply

    Thanks James, you save my day !

  5. charles July 20, 2017 at 3:08 pm - Reply

    We tried to do this, however, the load speed for files uploaded as attachment is pretty slow when used as a source for the video especially for 30 mins training videos (~100 – 140 GB).

    • James Farrer July 25, 2017 at 8:56 am - Reply

      Yeah, I’ve seen similar results. Unfortunately ServiceNow is not set up well for handling large video. For things like that I’ve most often seen companies use YouTube or some other video hosting solution.

  6. Patrick September 13, 2017 at 9:09 am - Reply

    Hi,
    Thanks.
    This works well with some browsers (Firefox, Chrome …) but not with Chrome
    Any idea

    • James Farrer September 15, 2017 at 12:21 pm - Reply

      There are a lot of potential places where things can break. When it’s just one browser then, from what I’ve seen and read, it is often a matter of support for the format of the video. Early on with the video tag in HTML 5 this was a major issue but has become less of an issue but not all formats for encoding a video are supported in all browsers. I believe mp4 videos using the H.264 format is the most common and generally supported across all browsers but there are a lot of alternatives and variations that may be causing a problem.

      As has been discussed in some of the other comments, if you can use YouTube, Vimeo, or some other similar video service they generally handle these details for you.

Leave A Comment