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 04:52 AM
But how do I get the sys_id from the onSubmit client script ?
The code is running as on onSubmit
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-26-2021 05:27 AM
you can use onSubmit client script with Synchronous ajax
Query sys_attachment and orderbydescending and then use ExcelParser to check the header and content
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-26-2021 09:58 AM
OK. My code is already synchronous Ajax calling a Script include and is an onSubmit Script
It is already querying sys_attachment, however, to Query the sys_attachment table I need the sys_id so I can perform the query
It is how I get this sys_id that is eluding me when running via the portal.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-26-2021 10:08 PM
If somehow you get the cart item sys_id that will work
or as of now do this
var gr = new GlideRecord("sys_attachment");
gr.addEncodedQuery("table_name=sc_cart_item");
gr.orderByDesc("sys_created_on");
gr.setLimit(1);
gr.query();
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-27-2021 05:02 AM
Won't necesaarily help on a busy instance
In the debugger, as the page loads you see this entries
the sys_id in the int sys_attachment? line is the sys_id that will be used in the sys_attachment table - its there - somewhere da8c70e62fe930903c345fd62799b6cc
After the form has loaded, if I now add an attachment with that same sys_id