is there and equivalent of "g_form.getElement('sysparm_item_guid').value" in the portal ?

poyntzj
Kilo Sage

Looking to revise one of my old Client Scripts which depends on checking a record while the user is in a catalog item

In the old CMS I would use  g_form.getElement('sysparm_item_guid').value which obviously fails in the Portal, but wondered if there is an equivalent I can use

I can see the Catalog Item is already assigned a new sys_id in the instance, but I cannot find how to access this Id from the portal.

 

Any ideas ?

 

TIA

24 REPLIES 24

BALAJI40
Mega Sage

Hi,

Do you want to access the URL parameters, if Yes please check below link,

Parse URL Parameters in a Client Script - ServiceNow Guru

No as the ID in the URL is the catalog item

What I am after is the ID that is associated with the Cart item

the g_form.getElement('sysparm_item_guid').value  used to get the the ID of the item in the cart so I could work with it

Perhaps to make this clearer

I am having to revisit an old attachment client script.  There are 3 components to this, count (easy), check on name (easy), check on content type - cold CMS working, portal - failing

The method I normally use is to call a GlideAjax to look at the sys_attachment table and check that the content type matches what is being searched for.  I cannot however get the sys_id that matches the record that is in the sys_attachment table. The g_form.getElement('sysparm_item_guid').value does this in the CMS 

As I can see the attachment in the table I know it somehow generates that link between the item on the users screen and their card, but it is eluding me

The name in most examples you see use "indexOf", which means if you search for ".xls", then the following will match "an.example.xls.exe".  My code is based on regex so can at least ensure the name ends with .xls

however, it is the content type as for my client the name is not quite enough, they want to ensure the content type is correct and this is where I am failing with adapting this code to work with the portal.

 

Cheers

 

Ankur Bawiskar
Tera Patron
Tera Patron

@poyntzj 

you can use g_form.getUniqueValue() to get the catalog item sys_id

it would work fine in native + portal

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader