- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-07-2018 02:51 PM
I want to validate that a user has attached a quote (e.g. uploaded .docx) to a catalog item before they submit the item to their cart. To do this I want to check the sys_attachment table for any attachments. When a user uploads the attachment, but before they add the item to their cart, SNow puts a record in sys_attachment with:
Table name = sc_cart_item
Table sys ID = <GUID of sc_cart_item instance>
The issue is SNow has not committed the sc_cart_item to the table until the user adds it to their cart so I can't get the sys_id of the sc_cart_item to check the sys_attachment table. But obviously the session has the GUID since it inserted the GUID to the sys_attachment table. Anyone know how to get a reference to the sc_cart_item GUID before the user submits the item to their cart?
Thanks in advance.
Solved! Go to Solution.
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-07-2018 03:01 PM
Try g_form.getParameter("sysparm_item_guid") in client script
Please mark this response as correct or helpful if it assisted you with your question.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-07-2018 03:01 PM
Try g_form.getParameter("sysparm_item_guid") in client script
Please mark this response as correct or helpful if it assisted you with your question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-21-2019 02:47 PM
Hi! Do you happen to have the full client script you used to achieve this? I am trying to accomplish the same thing but having no luck. Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-22-2019 06:36 AM
Hi Hannah,
Here is the onSubmit client script. Hope it helps!
function onSubmit() {
g_form.clearMessages();
var hasAttachment = false;
var hasAttGA = new GlideAjax('CatalogAttachmentUtil');
hasAttGA.addParam('sysparm_name', 'hasAttachment');
hasAttGA.addParam('sysparm_table_name', 'sc_cart_item');
hasAttGA.addParam('sysparm_table_sys_id', g_form.getParameter("sysparm_item_guid"));
hasAttGA.getXMLWait();
var myObj = hasAttGA.getAnswer();
var attachResp = JSON.parse(myObj);
//g_form.hideFieldMsg('attach_quote',true);
if(!attachResp.hasAttachment){
//g_form.showErrorBox('attach_quote','A quote attachment is required. Please attach a quote.',true);
g_form.addErrorMessage('A quote attachment is required. Please attach a quote using the paperclip icon.');
}else{
hasAttachment = true;
}
return hasAttachment;
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-22-2019 09:54 AM
Thank you so much for responding that was very nice!! Is this just for the platform side? I am trying to have this work on the portal so I think I will need to try something else