Getting Sys_id of record on portal

Jalen Dixon
Tera Contributor

Hello, 

 

I have tried getting the KB sys_id from a widget on the portal. I have tried different ways of doing so. 

 

1. 

var kbSysID = $sp.getParameter("sys_id") 

// this returns null

and

 

2.

var page_id = $sp.getParameter('id');
var spPage = new GlideRecord('sp_page');
spPage.get('id',page_id);
var page_sys_id = spPage.sys_id;

// this returns undefined

 

Neither way works. Is this related to versioning on KBs? Can someone please help me figure this out?

1 ACCEPTED SOLUTION

Hi @Jalen Dixon in that case you need to use below

var kbSysID = $sp.getParameter("sys_kb_id");

Regards
Harish

View solution in original post

4 REPLIES 4

Harish KM
Kilo Patron
Kilo Patron

Hi @Jalen Dixon the portal page you open, does the url contain sysid or KB number?

Regards
Harish

Yes, it says "sys_kb_id=sys_id". @Harish KM 

Hi @Jalen Dixon in that case you need to use below

var kbSysID = $sp.getParameter("sys_kb_id");

Regards
Harish

siva krishna M2
Tera Guru

Hello @Jalen Dixon ,

 

if your URL is in below format

instance/kb?id=page_id&sys_kb_id={sys_id}

 

then $sp.getParameter('sys_kb_id') gives the value of sys_id from the URL. So you have to use

var KbSysid =$sp.getParameter('sys_kb_id')