is there and equivalent of "g_form.getElement('sysparm_item_guid').value" in the portal ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-26-2021 01:36 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-26-2021 01:47 AM
Hi,
Do you want to access the URL parameters, if Yes please check below link,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-26-2021 02:52 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-26-2021 02:59 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-26-2021 03:03 AM
you can use g_form.getUniqueValue() to get the catalog item sys_id
it would work fine in native + portal
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader