Attachment file type client script - g_form.getUniqueValue help
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-18-2019 11:34 AM
Hello! I am trying to write a client script to work in the Service Portal that doesn't allow a user to submit the catalog item without an Excel file attached.
I've seen some community posts on this and they all say to use g_form.getUniqueValue() and then use that to query the sys_attachment table:
var sys_id = g_form.getUniqueValue()
var gr = new GlideRecord("sys_attachment");
gr.addQuery('table_name', 'sc_cat_item');
gr.addQuery('table_sys_id', sys_id);
gr.query();
I added console.log(sys_id); to see what sys_id the g_form.getUniqueValue() was returning. Then I checked the sys_id of table_sys_id column on the sys_attachment table for the attachment I just added and they are different. Why is that? Any other solutions to query the attachment table in a client script?
Thanks!
- Labels:
-
Service Catalog

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-18-2019 11:48 AM
Can you compare the sys_id of the attachment with the value of g_form.getUniqueValue() and check.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-18-2019 11:55 AM
They are different. The value returned by g_form.getUniqueValue() is the sys_id of the catalog item.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-18-2019 11:59 AM
So that is correct only, right.
Check the table_sys_id that is presnet in sys_attachment table. Check which catalog item it is ponting to?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-18-2019 12:06 PM
It is not pointing to any catalog item. Every time I attach something to this catalog item the table_sys_id is a new different one. How is this table_sys_id field getting populated? Is it something to do with the attachment is on the sc_cart_item table since it hasn't been submitted yet?