open kb directly instead of opening kb form

shaik17
Tera Contributor

Hi all,

I have related list in RITM which shows related kb articles attached to RITM, So when ever user clicks on kb article from related list  it should directly open published artcile instead of opening kb form in new window.

shaik17_0-1722509833964.png

This screen should be avoided

 

shaik17_1-1722509878791.png

This screen should be opened.

 

pls assist me how to acheive this,

Thanks.

3 REPLIES 3

NileshP
Tera Contributor

Hi,

Yes, it is possible to open a Knowledge Article directly to the attachment without opening the form in ServiceNow.

 

1. Create a UI Action: Go to "System Definition" > "UI Actions" and create a new UI Action with the following settings:

                   Table: kb_knowledge (Knowledge Article table)

                    Action name: open_attachment_directly

                    Client: true

2. Navigate to "System Definition" > "UI Scripts" and create a new UI Script with the following code:

 

function openAttachmentDirectly() {
  var knowledgeSysID = g_form.getValue('sys_id'); // Get the current Knowledge Article's sys_id
  var attachmentSysID = g_form.getValue('u_attachment_field'); // Replace 'u_attachment_field' with the actual field name storing the attachment sys_id

  if (attachmentSysID) {
    var attachmentUrl = new GlideURL('sys_attachment.do');
    attachmentUrl.addParam('sys_id', attachmentSysID);
    attachmentUrl.addParam('sysparm_referring_url', 'kb_knowledge.do?sys_id=' + knowledgeSysID);
    window.open(attachmentUrl.getURL());
  } else {
    alert('No attachment found.');
  }
}

 

3. Add the UI Action to the form layout: Edit the form layout of the Knowledge Article table (kb_knowledge) and include the newly created UI Action, "Open Attachment Directly."

 

Please mark the appropriate response as correct answer and helpful.
thanks

Hi @NileshP 
Actually it should open from related list the related list is in RITM. i have attached a screen shot for refference.
i didn't get 3rd point

shaik23_0-1722575741358.png

 

shaik23
Tera Expert

@Ankur Bawiskar, @Brad Tilton,@Community Alums please provide solution for this.