
- Subscribe to RSS Feed
- Mark as New
- Mark as Read
- Bookmark
- Subscribe
- Printer Friendly Page
- Report Inappropriate Content
With the world rapidly changing and the need for more remote work, videos have become an essential part of the remote work world. The need to post them within ServiceNow Knowledge articles is growing.
I will show you how to post a video from the ServiceNow video table (db_video) and a YouTube video.
Here is the documentation from ServiceNow that explains the steps I will be covering in this post.
If you want to add a video to a portal page, click the link below-
How to add a video to a Portal page
How to add a Microsoft Stream video to a Knowledge Article
The 1st thing we have to do is prevent ServiceNow from stripping out the code that enables the video to play within the HTML field. The HTML field is the Article body in a Knowledge article. By default, the HTML Sanitizer removes video code from HTML fields.
Step 1
Go to Knowledge Article that you want to post a video. Right-click on the "Article body" label. That should bring up a field context menu. In that menu, click on "Configure Dictionary" it should open a new window.
In the tab section at the bottom, there is a tab label "Attributes."
Click the new button.
Enter the following in the fields-
"Attribute" --> HTML Sanitize
"Value" --> false
hit submit.
This configuration is only done once, and this will affect all Knowledge Article - Article Body fields.
Step 2 *
Starting in the Quebec Release, this step has been added to the base code. This step may not be needed.
Modify the " HTMLSanitizerConfig" Script Include that allows attributes to be used in all HTML fields.
In the lefthand navigation menu, search bar type in "script include."
Click on the "Script Include" in the "System Definition" section.
Now in the list view, type in "HTMLSanitizerConfig" in the Name search bar.
Click on the "HTMLSanitizerConfig" to open it.
Go to the script section. You will need to add some code to this script that is provided by ServiceNow, which can be found here. We will NOT add the entire code snippet because there is a comma "" missing from the code that will throw a syntax error and drive you crazy trying to fix it.
In between lines 10 and 11, insert the code below in between the two closed brackets. IT IS VERY IMPORT that the code is in between the brackets.
embed: {
attribute: ["src", "type", "allowfullscreen", "allowscriptacces", "plugnspage"]
},
object: {
attribute: ["classid", "codebase"]
},
param: {
attribute: ["name", "value"]
}
It should look like the picture above. If you don't feel comfortable adding those lines of code can copy the entire example code below and paste it in the Script section.
var HTMLSanitizerConfig = Class.create();
HTMLSanitizerConfig.prototype = {
initialize: function() {},
HTML_WHITELIST: {
globalAttributes: {
attribute: [],
attributeValuePattern: {}
},
embed: {
attribute: ["src", "type", "allowfullscreen", "allowscriptacces", "plugnspage"]
},
object: {
attribute: ["classid", "codebase"]
},
param: {
attribute: ["name", "value"]
}
},
HTML_BLACKLIST: {
globalAttributes: {},
},
getWhiteList: function() {
return this.HTML_WHITELIST;
},
getBlackList: function() {
return this.HTML_BLACKLIST;
},
type: 'HTMLSanitizerConfig'
};
Step 3
Starting in the Quebec Release this step has been added to the base code. This step may not be needed.
Next, we will need to add elements to the "glide.ui.html.editor.extended_valid_elements" system property to stop the TinyMCE from striping them out.
Go to the lefthand navigation menu search bar and enter the following - sys_properties.list. It will open a list view of the system properties. In the name search bar, enter "glide.ui.html.editor.extended_valid_elements". Open the system property.
In the value, section enter the following code that ServiceNow provided
a[onclick|href|target|rel|media|hreflang|type|charset|name|rev|shape|coords|download|id|accesskey|class|dir|lang|style|tabindex|title]
It should look like this - now Save it.
Now you are ready to start adding videos.
Please make sure that the file extension you want to upload is allowed to be uploaded before we begin. If not, it will need to be added to the security setting before you can upload the video. Go to System Properties --> Security -->List of file extensions (comma-separated) that can be attached to documents via the attachment dialog. Extensions should not include the dot (.) e.g. xls,xlsx,doc,docx. Leave blank to allow all extensions.
In this step, we will add a video that is stored within the ServiceNow video table. Here are some things to keep in mind - (Here is the documentation)
- Not all Video formats can be added to the HTML field; here is the documentation for what video files are compatible.
- The following file formats are supported in the base system.
-
- MPEG-4 video .mp4
- WebM Video .webm
- The larger the file size, the longer it takes to download before the video starts. To reduce file size, you can reduce the bitrate, but doing so reduces the video's quality.
- Internet Explorer and Safari have difficulty streaming videos uploaded to the database. Attach a file rather than embedding if you intend to use one of these browsers or an unsupported file type. For more information on attaching files, see Add and manage attachments.
Video from the Video table (db_video)
To add a video to the Video table, you need to have the image_admin role or admin role.
You can add a video directly to the table or through the Knowledge article. It's up to you how you want to upload the video.
When entering the file name, it has to have the file's extension in the name that you are uploading. here is my example - test.mp4
select the file and click upload.
Click on the "add video icon" in the editor toolbar. It should default to "Video Library" in the Type dropdown option. Right under that is the video dropdown option. Select the video that you uploaded to the video table. A sample of the video show now is showing and playable. Click OK. There is also an Advanced Option that allows you to change the video's width and height in the video table.
The video should now show up in the Article body.
Save
Click on "view Article" Related Link. Make sure it works. Publish the Knowledge Article, and it will now show up on the Service Portal as well.
Add a YouTube video.
There are two ways to add a Youtube video to the Knowledge article. Using the add video icon button and the other is to paste the code directly to the source code using the source code icon button.
Before we begin, you will need a YouTube video.
I am going to use this YouTube video as my example.
https://www.youtube.com/watch?v=Q6TLWqn82J4
On the YouTube video page, click the "share" button, now click the "embed icon," and copy the code it provides.
<iframe width="560" height="315" src="https://www.youtube.com/embed/Q6TLWqn82J4" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
<inset code>
We will need both the link and the embed code for the steps below.
The 1st way to add the video to the Article is by adding the URL to the Insert/Modify Video popup window when you click on the "Add video" icon button. In the type field, it has the option for URL. Select that option.
IT will provide you with a Video file to enter a URL. You can enter the direct link there - https://www.youtube.com/watch?v=Q6TLWqn82J4. Starting in the Orlando release, it will convert that YouTube URL to the Embed version - https://www.youtube.com/embed/Q6TLWqn82J4. It should show you a preview that you can play. In the advance option, you can adjust the size and allow for the full-screen option.
Before the Orlando release, if you just enter the direct URL, it will NOT work. ServiceNow will not convert it. You will have to enter the embed link manually.
The 2nd way to add the YouTube video is to add the entire embed video code snippet that YouTube Provides. If you add the embed video code snippet in the URL video field in the step above, it will NOT work.
Once you have copied the code, there is a source code icon button in the HTML toolbar. Click it. Add the entire embed snippet code, and click OK to let ServiceNow reformat the code. At this point, it WILL NOT WORK; there is a piece of code that is missing. Click on the source code icon again and insert this line of code -
referrerpolicy="strict-origin"
I added it after the height code.
It should look like this -
Once you have that code in place, it will now play.
If you followed the steps above, you can now add videos to any Knowledge article.
These steps also work for Catalog items as well, but ONLY on the Service Portal. The back-end service catalog's UI framework doesn't play video, and it will not show up.
I tested this in New York, Orlando, and Paris releases.
- 22,514 Views
- « Previous
-
- 1
- 2
- Next »
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.