How to get the sys_id of a portal url (record producer)

Bart van der Wu
Mega Expert

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?

1 ACCEPTED SOLUTION

Bart van der Wu
Mega Expert

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);
}

View solution in original post

8 REPLIES 8

Harsh Vardhan
Giga Patron

have you tried with g_form.getUniqueValue() ?

Harsh Vardhan
Giga Patron

Tested with g_form.getUniqueValue() , its giving me the sys_id of Record producer on portal 

 

screenshot for reference:

find_real_file.png

 

 

 

I did try that but that did not work.
The whole script won't trigger anymore when I try this.
My guess is that this is because it's not a client script but a business rule that triggers after inserting.

I've also tried gs.getUniqueValue() but that doesn't pass a value at all.

may i know what exactly are you doing ? business rule wont work on record producer. 

 

 g_form.getUniqueValue() i have used on catalog client script on Record producer.