How to open a knowledge article by clicking the icon placed next to a non reference field

Community Alums
Not applicable

Hi All,

I need to open a specific published knowledge article by clicking the i button placed next to a field ,the article needs to open it, like how we have a preview record for reference field but the field I'm using is a not a reference field.

I have created a UI macro to show the button, but how to open that particular record by clicking the button and the knowledge article needs to be a published one only.

 

I tried the below code in UI macro,but it is not working, it is opening in a new tab and opening a new knowledge article not the one I have specified. I want this need to be opened in the current window only.

<?xml version="1.0" encoding="utf-8" ?>
<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">
    <span id="${jvar_n}" onclick="showDail()" title="Show countries dail in numbers" alt="Show countries dail in numbers" tabindex="0" class="btn btn-default btn-ref icon icon-info active glide-popup-target">
    </span>
    <script>
      function showDail()
        {
        var kb=new GlideRecord("kb_knowledge");
kb.addQuery('workflow_state','published');
kb.addQuery('number','KB0010002');
kb.query();
if(kb.next())
    {
        
        var artcile=kb.sys_id;
        //alert(artcile);
        var URL="kb_knowledge.do?"+artcile;
        window.open(URL);
        
    }
        }
    </script>
</j:jelly>

 

Anyone please help on this ,

Thanks.

3 REPLIES 3

Akif_Shah
Kilo Sage
Kilo Sage

Can you change your URL to 

var URL="kb_view.do?sysparm_article=KB0010002";

 

if it works you can change it to 

var URL="kb_view.do?sysparm_article=" + <KB Number>";

 

Community Alums
Not applicable

Hi,

I tried this one its working, but its opening in a new tab, but I wants that to be in a current window only, Is there any solution.

try using

window.open(URL, '_self');