Need to redirect into knowledge article.

SandeshR5514624
Tera Contributor

Hello Community,
In cmdb_ci table need to crate a xyz name link ( In related links) which redirect to specific knowledge article which is published in prod.
Please guide me how to create a related link (UI action) on cmdb_ci table in details.

Cheers,
Sandesh

3 REPLIES 3

haseena ayesha
Giga Guru

Hi Sandesh,

Hope you are doing well.

Please try this one:

Solution:

You can achieve this by creating a UI Action on the 'cmdb_ci table and configuring it to appear as a Related Link.

Steps:

  1. Navigate to System Definition → UI Actions and create a new record
  2. Set the fields as:
    • Table: cmdb_ci
    • Check Form context menu (to show under Related Links)
  3. In the script section, use:

Script as : 

action.setRedirectURL('/kb_view.do?sysparm_article=KB0012345');

Replace with your KB article number.

Alternatively, using sys_id:

Script as:

action.setRedirectURL('/kb_view.do?sys_id=YOUR_KB_SYS_ID');

  1. Save and test on any CI record.

Optional:
If you want dynamic behavior, create a reference field to kb_knowledge and use it in the script to redirect dynamically.

If each CI should open a different KB article:

Step 1: Add field to cmdb_ci

u_kb_article (Reference → kb_knowledge)

Step 2: Update Script

JavaScript

if (current.u_kb_article) {

action.setRedirectURL('/kb_view.do?sys_id=' + current.u_kb_article);

} else {

gs.addInfoMessage('No Knowledge Article linked to this CI');

}

 

Hope this helps! If it answers your question, please consider marking it as Helpful or accepting it as a solution.
Thank you!

 

 

 

Tanushree Maiti
Tera Patron

Hi @SandeshR5514624 

 

Try this:

 

  1. Navigate to System Definition > UI Actions in your ServiceNow instance.
  2. Click New :
    • Name: XYZ (or your desired display name)
    • Table: Configuration Item [cmdb_ci]
    • Active: Checked
    • Form context menu : Checked
  1. Uncheck Client (this executes server-side).
  2. In the Condition field, you can restrict when the link is visible (like  gs.hasRole("sn_cmdb_read")).

 

function redirectToKnowledge() {

    var kbNumber = 'KB5234568';  //Replace your specific published Knowledge Article Number

    var grKB = new GlideRecord('kb_knowledge');

    grKB.addQuery('number', kbNumber);

    grKB.addQuery('workflow_state', 'published');

    grKB.query();

        if (grKB.next()) {

        var targetUrl = 'kb_view.do?sys_kb_id=' + grKB.sys_id;

        action.setRedirectURL(targetUrl);

    } else {

        gs.addErrorMessage('The linked Knowledge Article could not be found or is not published.');

    }

}

redirectToKnowledge();

 

Please Accept the solution if it assisted you with your question & Mark this response as Helpful.
Regards
Tanushree Maiti
ServiceNow Technical Architect
LinkedIn: https://www.linkedin.com/in/tanushreemaiti

Tejas Adhalrao
Kilo Sage

Hi @SandeshR5514624 ,

1) click on form header > configure > UI action 

TejasAdhalrao_0-1779677476200.png

2) create Ui action record 

TejasAdhalrao_1-1779677531140.pngTejasAdhalrao_2-1779677543429.png

 

3) save and link visible on Form and test. 

TejasAdhalrao_3-1779677602439.png

 

 

here i have created UI action on incident table you can follow this steps for cmdb_ci Table. 

 

 

If this response was helpful, please consider marking it as Correct and Helpful. You may mark more than one reply as an accepted solution.

thanks ,

tejas😊