- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-20-2018 03:41 PM
I have a requirement where i need to check if the catalog item have 2 attachments , if not it should not submit ,
i am able to check the attachment by using on submit client script on the catalog item but how and where to include the count ?
Can some one help me with that
function onSubmit() {
//Type appropriate comment here, and begin script below
var proof = gel('sysparm_item_guid').value;
var att = new GlideRecord("sys_attachment");
att.addQuery("table_name", "sc_cart_item");
att.addQuery("table_sys_id", proof );
att.query(att);
if (!att.next()) {
alert("Please include the attachments");
return false;
}
return true;
}
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-21-2018 06:18 AM
You can try with this code:
var proof = gel('sysparm_item_guid').value;
var rowcount=0;
var attachment = new GlideRecord("sys_attachment");
attachment.addQuery("table_name", "sc_cart_item");
attachment.addQuery("table_sys_id", proof);
attachment.query();
while (attachment.next()) {
rowcount++;
}
//alert("Row "+rowcount);
if(rowcount <= 2)
{
alert("message");
return false;
}
else
{
return true; }
}
https://community.servicenow.com/community?id=community_question&sys_id=cd49c325db5cdbc01dcaf3231f961992
Thanks
Shashikant
Hit Helpful or Correct on the impact of response.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-28-2023 09:04 AM
Hi @Mike Patel ,
In the above reply, Where is the definition of this "getSCAttachmentCount() ??

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-28-2023 11:03 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-21-2018 06:18 AM
You can try with this code:
var proof = gel('sysparm_item_guid').value;
var rowcount=0;
var attachment = new GlideRecord("sys_attachment");
attachment.addQuery("table_name", "sc_cart_item");
attachment.addQuery("table_sys_id", proof);
attachment.query();
while (attachment.next()) {
rowcount++;
}
//alert("Row "+rowcount);
if(rowcount <= 2)
{
alert("message");
return false;
}
else
{
return true; }
}
https://community.servicenow.com/community?id=community_question&sys_id=cd49c325db5cdbc01dcaf3231f961992
Thanks
Shashikant
Hit Helpful or Correct on the impact of response.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-21-2018 06:27 AM
Thanks Yadav
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-12-2019 10:47 AM
this line:
var proof = gel('sysparm_item_guid').value;
is not working for me, why so? I'm applying it to a record producer and to my understanding gel('sysparm_item_guid').value refers to current CART item in the order guide, where CART means it is being used for a catalog item rather thatn a record producer