SP Widget Server Script get sys_id of calling catalog item

xiaix
Tera Guru

As I replied to This community question

I have a catalog item on the Service Portal to where I added a macro variable that loads a widget:

find_real_file.png

 

Now, when this widget loads, I want to grab the sys_id of the calling catalog item because in the Server Script, I want to query the item_option_new table to get the sys_id's of all the variables:

 

find_real_file.png

 

 

When the widget initially loads, it runs the Server Script and that's where I can't seem to get the sys_id of the calling catalog item.

 

The only way that I've found do what you're trying to do is by doing this:

 

find_real_file.png

find_real_file.png

find_real_file.png

 

However, this is not the way I want to go about it.  I need to grab that sys_id before any of the HTML Template code gets rendered.

1 ACCEPTED SOLUTION

Jon Barnes
Kilo Sage
The sys_id of the catalog item will be in the URL, so you should be able to get it from there with: $sp.getParameter(‘sys_id’)

View solution in original post

2 REPLIES 2

Jon Barnes
Kilo Sage
The sys_id of the catalog item will be in the URL, so you should be able to get it from there with: $sp.getParameter(‘sys_id’)

Yep, that'll do it.  This is perhaps the only way in which it can be done too... i'm only assuming.  So, I'll mark this as correct.  Thanks Jon for taking time on a Saturday to answer my question!