Get current page in service portal

scottl
Kilo Sage

How does one get the sys_id of the current page that the user is viewing in the service portal?

1 ACCEPTED SOLUTION

Hi Scott,



My bad. I thought you were trying to retrieve sys_id from the URL.


You can try below code to get the sys_id of current page,



var page_id = $sp.getParameter('id');


var gr = new GlideRecord('sp_page');


gr.get('id',page_id);


var page_sys_id = gr.sys_id;



Hope this helps.


Do not feel shy to mark correct or helpful answer if it helps or is correct.



Best Regards,


Nitesh Asthana


View solution in original post

13 REPLIES 13

Nitesh Asthana1
Kilo Guru

Hi Scott,



If you want to get sys_id of the current record in widget, you can get it by putting below code at widget's server script field,



$sp.getParameter("sys_id");



Hope this helps.


Do not feel shy to mark correct or helpful answer if it helps or is correct.



Best Regards,


Nitesh Asthana


This is incorrect as this returns null, because that's assuming you're passing a page sys_id via the url.


Hi Scott,



My bad. I thought you were trying to retrieve sys_id from the URL.


You can try below code to get the sys_id of current page,



var page_id = $sp.getParameter('id');


var gr = new GlideRecord('sp_page');


gr.get('id',page_id);


var page_sys_id = gr.sys_id;



Hope this helps.


Do not feel shy to mark correct or helpful answer if it helps or is correct.



Best Regards,


Nitesh Asthana


That makes sense.   However I thought there might of been a method as part of the $sp object to return the page object.