- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-19-2019 11:13 AM
I'm using `g_form.getUniqueValue()` from a service catalog's onSubmit method and it always returns the same ID which is not a valid one.
I am adding an attachment to the SC item and I can see the sys id in the attachment table, and it does not match the sys_id that I get from `g_form.getUniqueValue()`.
In fact, every time I create a new SC request I get the same value for ``g_form.getUniqueValue()`.
How do I get the actual id of the SC request I'm making?
In the below code, if I create the service catalog request 20 times, I always get the same sysid
function onSubmit() {
var sysid = g_form.getUniqueValue();
// var attach = new GlideRecord('sys_attachment');
// attach.addQuery('table_sys_id',sysid);
// attach.query();
// if(attach.next()){
// alert("form contains attachment for " + sysid);
// } else {
// alert("No attachment for " + sysid);
// }
var shouldHaveAttachment = g_form.getValue("use_spreadsheet") === "true";
alert("Submitting " + sysid + " : false for now - expecting spreadsheet: " + shouldHaveAttachment);
return true;
}
Solved! Go to Solution.
- Labels:
-
User Interface (UI)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-19-2019 12:20 PM
I get the same ID all the time, I looked at the DOM and found hidden values, and either of them work:
sysparm_attachment_cart_id or sysparm_item_guid - so the code is g_form.getParameter('sysparm_attachment_cart_id');

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-19-2019 11:22 AM
That should return the sys_id. You could try :
g_form.getParameter('sysparm_id')
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-19-2019 11:28 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-19-2019 11:59 AM
HI,
YOu want id of the request or the catalog item?
BEcause you have script on catalog item, so it will always give you same sys_id.
Thanks,
Ashutosh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-19-2019 12:20 PM
I get the same ID all the time, I looked at the DOM and found hidden values, and either of them work:
sysparm_attachment_cart_id or sysparm_item_guid - so the code is g_form.getParameter('sysparm_attachment_cart_id');