
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-28-2018 11:14 AM
Hi everyone,
So I've googled for quite some time to try and see how to go about doing this, but I'm struggling. This isn't your ordinary navigate by URL schema, please take note that it's for the Service Portal, specifically. And by that, I have an icon-link, I would like to have that point to the create incident record producer (which is a catalog item and so I'm unable to follow this format: https://<instance name>/<sp url suffix>?id=<page id>&<page parameters>).
How can I set up a widget to navigate to the record producer (customer facing, not back-end form view) of the incident within the service portal AND fill in specific values for category, subcategory etc.?
I figured out the URL schema for the SP to open the back-end incident form and fill in values, but I need the customer facing version.
Anyone got any ideas?
Or how can I take: sp?id=sc_cat_item&sys_id=<sysid of record producer> and somehow pass values to that, unfortunately I don't think that's allowed. As I'd need to replace sys_id in that line to sys_id=-1 to be able to open a form to create, but again, it won't know which record producer or category item to open as we just took that sys_id out...
Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-28-2018 12:51 PM
I found the mistake of my ways. So it seems that $scope.page.g_form isnt available to all widgets. I had to add a macro with a "widget" set to the new widget.
then it works.
So you'd have to add that variable on every form you want this to work on.
If you want to see it in action, hit me up on sndevs.slack.com @jace invite url: https://snowslack.herokuapp.com/

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-28-2018 12:28 PM
The script should log some things in the console, you may need to decode the url parameters.
As it stands if your url was as you pasted;
https://domain.service-now.com/sp?id=sc_cat_item&sys_id=<sys_id>&sysparm_query=category%3DHardware
It should have an output of;
setting sys_id => <sys_id>
setting sysparm_query=category%3DHardware
If you wanted to set the variable "category" if you had appended `&category=Hardware` it should set it to hardware
https://domain.service-now.com/sp?id=sc_cat_item&sys_id=<sys_id>&sysparm_query=category%3DHardware&category=Hardware

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-28-2018 12:33 PM
Do you know where to see the console log while in the SP?
Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-28-2018 12:41 PM
Figured it out, it's through your web browser, right? So I use Chrome > More Tools > Developer > Console.
Not seeing anything giving me the sys_id though
Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-28-2018 12:51 PM
I found the mistake of my ways. So it seems that $scope.page.g_form isnt available to all widgets. I had to add a macro with a "widget" set to the new widget.
then it works.
So you'd have to add that variable on every form you want this to work on.
If you want to see it in action, hit me up on sndevs.slack.com @jace invite url: https://snowslack.herokuapp.com/

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-28-2018 01:43 PM
So I just added a macro to the record producer form and assigned the widget to the "gform" widget I made, which is a copy/paste of the script you listed originally.
So should I be seeing things in the console log now? that would show the sys_id and category I specified?
The direct URL, that I listed above that I tried, still isn't working.
Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!