Maik Skoddow
Tera Patron
Tera Patron

find_real_file.png

 

Knowledge articles can grow so extensive that you may lose track of their contents. Here, it would be helpful to have navigation aids at the beginning of the article (for example, a table of contents) to navigate to the relevant part with one click.

Unfortunately, OOTB  the rich text editor does not offer the possibility to do this, but you can enable the respective buttons or write the necessary HTML code yourself. This article will demonstrate how to do it.

        
Table of Contents

 

Definition of jump targets

Targets of local navigation jumps are called "anchors" and there are two options for implementing them.

 

(1) Activate and use the corresponding button in the editor toolbar

For fields of type "HTML", content editing is done in a so-called rich text editor and ServiceNow uses TinyMCE, one of the best-known open source projects, for this purpose. This editor has a lot of configuration options and features which can be greatly expanded by the many plugins.  Basically, the configuration of the offered buttons in the toolbar can be controlled via the following system properties:

  • glide.ui.html.editor.v4.enabled_plugins
    That system property specifies all additional TinyMCE plugins that should be loaded.

  • glide.ui.html.editor.v4.toolbar.valid.buttons
    That property lists all valid buttons which can be used for further configuration of the toolbars. The buttons are defined via the loaded TinyMCE plugins and thus result from the values specified in the previous system property.

  • glide.ui.html.editor.v4.toolbar.line1 / glide.ui.html.editor.v4.toolbar.line2
    These system properties have stored all provided buttons in a comma-separated list. Using the pipe char will create a button group. The "anchor" value must be entered at the desired position to provide the corresponding functionality. 

 

After this is accomplished, the anchor icon will be offered in the toolbar for most of the HTML based fields:

 

find_real_file.png

 

However, in the rich text editor of the "Article body" field of knowledge articles the anchor icon is still missing. In addition, the arrangement of the icons here is quite different from the HTML fields in other tables. 

 

find_real_file.png

 

This is due to the fact that all settings can be defined individually for each field, which will override the global settings.

To change the behavior of the "Article body" field, open the corresponding Dictionary entry in the "Advanced" view (a respective link for that is offered in the "Related Links" section):

 

find_real_file.png

 

At Dictionary field "Attributes" the configuration format differs from the one for system properties, however the basic principle is the same. Place the anchor icon at the desired location and then save the dictionary entry.

With the help of the new anchor icon, you can place anchor based jump targets wherever you want: 

 

find_real_file.png

 

(2) Write the necessary HTML code yourself

If you cannot find a system administrator to enable the anchor icon you can also the underlying HTML code by yourself. An anchor is defined as:

<a name="ANCHORNAME"></a>

 

The attribute value ANCHRORNAME has to be replaced, and the complete HTML tag can be placed wherever you want:

<h1><a name="chapter1"></a>Chapter 1</h1>

 

Definition of jump links

After defining jump targets, it is now time to create the links that will allow you to jump there.

To do this, simply select the text or image and then click on the link icon in the toolbar or press the key combination CTRL+K. However, instead of a normal URL, the name of the jump target is entered with a prefixed hash character:

 

find_real_file.png

 

Result

After saving the form and selecting "View Article" you can try the recently created link:

 

find_real_file.png

 

Comments
Leri Andrews
Tera Guru

Please can you tell me why I cannot send people a link to a specific place in the article by appending the anchor name to the url.  It works fine for other websites but not ServiceNow.  I have received an answer to my community post but I still don't understand why the articles work different. https://community.servicenow.com/community?id=community_question&sys_id=cfc874f6db88bc9014d6fb2439961933

Maik Skoddow
Tera Patron
Tera Patron

Please my answer at your community question.

Mary Gerhardt
Tera Contributor

We have a Glossary article that we link to from other articles, using anchor links to the specific terms. The anchor links stopped working after we upgraded to Quebec. Links from articles now bring users to the top of the Glossary article, not to the named anchor location within the article. 

Is there a solution for this? 

Maik Skoddow
Tera Patron
Tera Patron

I just followed my own instructions on a Rome instance it is still working.

As you did not provide more details, I have no idea what your issue is.

Leri Andrews
Tera Guru

Interestingly my problem seems to have solved itself after launching a new service portal where links in knowledge articles to other knowledge article anchors now work. e.g.  https://portalprod.service-now.com/portal?id=kb_article_view&sys_kb_id=01k4b63ddb2bs054d65bf592f396194&table=kb_knowledge#section2

 

Johan van den H
Kilo Sage

How can we link to an anchor in another text section without having the reader to open that section first?

We are using collapsed fields (like the Instructions for employees field in the screenshot below and want to be able to link to anchors in the collapsed fields.

 

find_real_file.png

 

 

Jerry kk Wong
Kilo Sage
Kilo Sage

@Maik Skoddow - Thank you for this post as this was useful.  Has there been a reply to @Johan van den H post as this is interesting to be able to link anchors to the collapse fields.

 

Keszia
Giga Guru

I'm trying to use the HTML code in the Utah release, and something loads into the article body, but it isn't clickable/usable. Does this still work in later releases?

Keszia
Giga Guru

To answer my own question - I have fount that adding id="anchor" into the source code, then using #anchor at the end of the URL takes you to the anchor, based off of this online reference.

id="anchor"

Examples:

<p id="anchor">This is a paragraph I want to link to.</p>
<h2 id="anchor2">This is the anchor which is also a heading.</h2>
Version history
Last update:
‎02-04-2021 07:26 PM
Updated by: