pass parameter to page with widget via page url

ggg
Giga Guru

in service portal

i have a page with one widget

the server script on the widget needs a sysid

i thought i could put the sysid in the url

and retrieve it in the server script on my widget, like so:

 

my url is: myservicenow.com/sp?id=mypageid&sysparm_my_sysid=1111111

    >> sp?id=mypageid    this is the id of my sp page

server script:

function($sp){

var sysid = $sp.getParameter('sysparm_my_sysid');

gs.info(sysid);

}

this is not working.

i have looked at documentation and community posts ... i am not sure if i am doing this correctly.

help.

1 ACCEPTED SOLUTION

Chuck Tomasi
Tera Patron

You don't need to declare $sp, it's built in. Here's an example of the start of one of my scripts that I use a couple URL parameters...

(function() {
  /* populate the 'data' object */
  /* e.g., data.table = $sp.getValue('table'); */

  var cardID = $sp.getParameter('card_id');

View solution in original post

2 REPLIES 2

Chuck Tomasi
Tera Patron

You don't need to declare $sp, it's built in. Here's an example of the start of one of my scripts that I use a couple URL parameters...

(function() {
  /* populate the 'data' object */
  /* e.g., data.table = $sp.getValue('table'); */

  var cardID = $sp.getParameter('card_id');

omg, it was that simple 🙂

i removed $sp from function and voila!