O

ne of my favorite things about doing ServiceNow work at Crossfuze is the opportunity to collaborate with our customers to come up with unique ways to solve problems. I’m usually brought in to train and teach, but there’s not a client I’ve worked with that hasn’t taught me a few things as well. A couple of weeks ago, a ServiceNow administrator at one of our clients, Shannon Thurston, came up with a great idea for building a common CSS stylesheet for all of their knowledge articles. This idea can be used throughout the system, and is pretty simple to implement. In this article I’ll show you how to leverage custom CSS stylesheets in non-CMS pages in ServiceNow.

KB Style Sheet

The first step to making this work is to define your style sheet as shown in the screenshot above. What I’ve done is obviously just an example and you can customize this however you want. Style sheets can be defined under the ‘Content Management’ application in your left navigation toolbar.

Next, right-click the style sheet record header and copy the sys_id value. You’ll need the sys_id in order to tell the system which style sheet to use.

Now comes the tricky part. You need to determine where to add the link to your style sheet. In the knowledge base example, there are a couple of options. The first is simply to place the following html tag into your article text field while in the HTML code view (where the ‘href’ attribute includes the sys_id for your CMSstyle sheet record).

<link href="5b2281fb87e130005736b4c329434dfb.cssdbx?" rel="stylesheet" type="text/css" />

Shannon’s idea was to leverage the ‘kb_view_custom’ UI macro to include the style sheet link in one place for all articles. You can do this by creating or modifying the ‘kb_view_custom’ UI macro under ‘System UI -> UI macros’ to include the same code as shown above (where the ‘href’ attribute includes the sys_id for your CMS style sheet record).

Here’s one example of what this might look like…

Styled KB Article