- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-17-2020 05:02 AM
Hi there,
I'm facing an issue retrieving the sys_id of a record producer from a URL on the Service Portal.
Old situation:
I have multiple record producers that were reached via the backend catalog:
/nav_to.do?uri=%2Fcatalog_home.do%3Fsysparm_catalog%3D6bf67dbcdbeac850ee8a9635db961912%26sysparm_catalog_view%3DThe_Catalog
If you open an item (record producer) there you get the following URL:
/nav_to.do?uri=%2Fcom.glideapp.servicecatalog_cat_item_view.do%3Fv%3D1%26sysparm_id%3Dbb9c8bbcdb620c50ee8a9635db96197c%26sysparm_link_parent%3D96d8b570db2ec850ee8a9635db9619ee%26sysparm_catalog%3D6bf67dbcdbeac850ee8a9635db961912%26sysparm_catalog_view%3DThe_Catalog
In the record producer I can obtain the sys_id of the record producer via the following code:
var sid = gs.action.getGlideURI().getMap().get('sysparm_id');
This worked like a charm.
New situation:
The record producers will be reached via the Service Portal and so the URL changes:
/sp?id=sc_cat_item&sys_id=bb9c8bbcdb620c50ee8a9635db96197c
Now I'm unable to get the sys_id of the record producer anymore.
It is in the URL but I cannot figure out how to retrieve it.
Does anybody have a clue what code to use?
Solved! Go to Solution.
- Labels:
-
Multiple Versions
-
Service Catalog
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-17-2020 06:14 AM
Investigating a bit further with Mark Roethof the issue was solved.
The issue was that in the portal you cannot obtain the URL for information while this is possible via the backend.
As a workaround I've created an additional field in a variable set. This reference field to sc_cat_item_producer is auto filled and made invisible by an onload client script:
function onLoad() {
var recordProducer = g_form.getUniqueValue();
g_form.setValue('record_producer', recordProducer);
g_form.setVisible('record_producer', false);
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-17-2020 05:29 AM
Hi there,
Are you after the sys_id of the record producer? Or the record you are about to produce 🙂
The record producer: g_form.getUniqueValue() will do.
The new record: no go. The code you pasted will also not work on Service Portal.
If my answer helped you in any way, please then mark it as helpful.
Kind regards,
Mark
2020 ServiceNow Community MVP
2020 ServiceNow Developer MVP
---
LinkedIn
Community article list
Kind regards,
Mark Roethof
Independent ServiceNow Consultant
10x ServiceNow MVP
---
~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-17-2020 05:39 AM
Or is your script about service scripting after the Record Producer has been submitted? In that case would table "Item Produced Records" help you? This contains a relation between the submitted record producers, the record created, which record producer, etc..
sc_item_produced_record
If my answer helped you in any way, please then mark it as helpful.
Kind regards,
Mark
2020 ServiceNow Community MVP
2020 ServiceNow Developer MVP
---
LinkedIn
Community article list
Kind regards,
Mark Roethof
Independent ServiceNow Consultant
10x ServiceNow MVP
---
~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-17-2020 06:14 AM
Investigating a bit further with Mark Roethof the issue was solved.
The issue was that in the portal you cannot obtain the URL for information while this is possible via the backend.
As a workaround I've created an additional field in a variable set. This reference field to sc_cat_item_producer is auto filled and made invisible by an onload client script:
function onLoad() {
var recordProducer = g_form.getUniqueValue();
g_form.setValue('record_producer', recordProducer);
g_form.setVisible('record_producer', false);
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-10-2020 08:39 AM
The code can be further improved by not storing the value in a var, for more efficiency (harder to read).