RP.getParamterValue('sysparam_name') not working

Jag5
Tera Guru

Hi, 

I am trying to get the sys id from the url of kb_view UI page. But it is not working. Below is the script I am using and not sure where I am doing wrong. Any help is much appreciated. 

Here is the url of knowledge article: https://dev58373.service-now.com/kb_view.do?sys_kb_id=e97ee81eff6002009b20ffffffffffe0

<g:evaluate var="jvar_url" >

// Retrieve the record number passed in the URL Param 'sysparm_number'
var number = RP.getParameterValue('sys_kb_id');

gs.log('KB Number:' + number);

// Create a variable to hold our result
var answer;

// GlideRecord query to find the record
var gr = new GlideRecord('kb_knowledge');
gr.addQuery('sys_id', number);
gr.query();
if(gr.next()){

// Found a record with the matching number
answer = gs.getProperty('glide.servlet.uri') + 'nav_to.do?uri=' + gr.sys_class_name + '.do?sys_id=' + gr.sys_id;
answer;
}else{
// Couldn't find a record with the matching number
answer = 0;
answer;
}
</g:evaluate>

Thank you,

Jag. 

5 REPLIES 5

Saikiran Gudur1
Mega Guru

Hi Jag,

 

RP.getParameterValue() is used when you try to pass the parameter from some other page to the UI page when a redirection happens.

Eg:

Open a incident record. Assume a custom link is there to click in which you tried redirecting to your UI page then this method works.

 

But as per per your requirement you are just trying to pass a parameter from URL to the UI page.

This can be achieved by passing it as "sysparm_sys_kb_id".

(https://dev58373.service-now.com/kb_view.do?sysparm_sys_kb_id=e97ee81eff6002009b20ffffffffffe0)

And catching it  in UI page using ${sys_kb_id} . (replacing RP.getParameterValue()).

 

Thanks,
Saikiran Guduri (NOW)
(Please mark the answer as correct answer/helpful/accept the solution if it helps)

Hi Saikiran,

Thank you for your response. 

I am trying to display a message like below when a flag article button is clicked on a kb article which has already been flagged. So, I am using the above the script in kb_view_suggest ui page trying to pull the sys id from kb_view page url. Am I approaching the wrong method? Thank you. 

find_real_file.png 

Thanks,

Jag.

Hey Jag in your UI action the code to display the GlideDialogWindow is there right? setPreference() to that object.

var gdw = new GlideDialogWindow('kb_view_suggest');
      gdw.setTitle('Flag this article');
      gdw.setPreference("sys_kb_id", g_form.getUniqueValue());
      gdw.render();

 

In the UI page replace 'RP.getParameterValue()' with RP.getWindowProperties().get('sys_kb_id');

 

Thanks,
Saikiran Guduri (NOW)
(Please mark the answer as correct answer/helpful/accept the solution if it helps)

Saikiran Gudur1
Mega Guru

Hey Jag in your UI action the code to display the GlideDialogWindow is there right? setPreference() to that object.

var gdw = new GlideDialogWindow('kb_view_suggest');
      gdw.setTitle('Flag this article');
      gdw.setPreference("sys_kb_id", g_form.getUniqueValue());
      gdw.render();

 

In the UI page replace 'RP.getParameterValue()' with RP.getWindowProperties().get('sys_kb_id');

 

Thanks,
Saikiran Guduri (NOW)
(Please mark the answer as correct answer/helpful/accept the solution if it helps)