
- 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 05:07 PM
I have it working on my pdi feel free to poke around;
https://dev32369.service-now.com/sp?id=sc_cat_item&sys_id=b480811a0f021300fc69cdbce1050ece&description=test2
u: slack
p: slack

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-29-2018 05:45 AM
Firstly, thank you very much for all of your replies and working with me. That must can't be said enough.
So I did login to your dev and it works beautifully.
I'll recap what I did and hopefully you can spot any missteps.
So I created a brand new widget and called it "gform" and only placed the script you mentioned above, in the client script section. That's it. Then I went to designer for the sc_cat_item OOB page and dragged that widget on to it, it disappeared (not visible), which I think is fine. I then went to my create incident record producer and added a macro variable with nothing else done to it except for the widget section I selected "gform". I then went back to my SP and navigated to that cat item (incident record producer) and saw the link in my URL bar (https://dev.service-now.com/sp?id=sc_cat_item&sys_id=3f1dd0320a0a0b99000a53f7604a2ef9). I then simply added &category=Hardware to the end of it and attempted to load the page.
Unfortunately, it's not changing the category. I tried with comments as well, and that doesn't work either.
I recall you saying something about looking for your sys_id in the console log? But I have it listed above, unless it is generating a different one through the script/widget I made and I need to use that instead?
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-29-2018 05:55 AM
Nevermind, I got it. So...what happened was...I went to the URL in your script at the top, to see the website and what it was about and copied and pasted that (instead of your exact script above) and those two had variations...not sure if you edited it to make it work or whatever, but I went with the website version. I just walked back through my steps and tried yours and sure enough, it works.
You're the best man!
Side question...what are your thoughts on this "breaking" in the future? Is it pretty basic stuff that shouldn't break with an upgrade? I know we can't predict everything, but there are some situations where we have a stronger feeling or not.
Thoughts?
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-29-2018 06:46 AM
I don't think SN will remove widget's ability to access $scope, and $location so I think this is pretty future proof.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-29-2018 07:29 AM
Thanks. I appreciate all your help.
Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!