\$sp.getParameter("sys_id") returning "null" value in Service portal
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-04-2016 09:01 AM
I am using $sp.getParameter("sys_id") in widget ,but it retun null,
anyone can help on this ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-23-2016 02:10 AM
Hi All,
Is there a way to get the sys_id of the widget in server script?
In Client script and html it is available as c.widget.sys_id
But when I tried it in server script, it is not working.
Any alternatives?
Thanks
Alli
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-23-2016 05:16 PM
A way I solved this was using sessions to store the URI values. So when the Model is run from the watcher it looks to a session variable for the page URI which was set on page load. For example...
var session = new GlideUtilSession();
var sys_id = $sp.getParameter("sys_id");
if (sys_id != null ) {
// save value for record watcher as $sp not maintaining GET vars from initial page load. (due to request to model in the background).
session.set("param_sys_id", sys_id);
}else{
//
sys_id = session.get("param_sys_id");
}
Hope this helps.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-07-2016 09:06 PM
Update: I've updated this code so that it is only utilised where the issue lies and that's within the post to the server (watchers etc...) because otherwise it will conflict with general page loading with certain scenarios and I've encountered.
var session = new GlideUtilSession();
var sys_id = $sp.getParameter("sys_id");
if (sys_id != null ) {
// save value for record watcher as $sp not maintaining GET vars from initial page load. (due to request to model in the background).
session.set("param_sys_id", sys_id);
}else{
//
if (input) {
sys_id = session.get("param_sys_id");
}
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-17-2016 04:57 PM
Scott,
I am facing the exact same issue and came across your post after spending several hours figuring this out. I am trying to use the same code that you are using, but I get this error message "GlideUtilSession" is not defined. Did you have this issue? Im using this on a widget server script on Helsinki patch 4.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-18-2016 04:33 PM
This is because that's a custom Script Include that I wrote which handles the GET and SET of session variables. The core of this class is this method in-which both get() and set() call.
...
_session : function(key, value)
{
if (typeof(value) != "undefined") {
// set a session value
gs.getSession().putClientData(key, value);
}
return gs.getSession().getClientData(key);
},
....
Hope this helps.