- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-11-2016 01:51 PM
Hi,
I'm wondering if anyone has successfully implemented functionality that would require an attachment before a field on the form can change. This is not on submission of a catalog item.
Here is our use case:
Legal department puts cases in a 'Pending' state. In order for them to be removed from pending, the user needs to attach a document. It can't be just any document attached either, the user would purposefully need to click a button that said something like "Remove from Pending - Doc Attached" or something.
Thanks in advance for any help or advice!
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-11-2016 04:31 PM
Hi Adam,
Here is the script. Just make sure you add a condition as per your req to trigger it. It will be client script.
Script :
function onSubmit() {
var att = new GlideRecord("sys_attachment");
att.addQuery("table_name", "change_request");
att.addQuery("sys_created_by", g_user.userName);
att.addQuery("sys_created_on", '>=', 'javascript:gs.minutesAgo(10)');
att.query();
if (!att.next()) {
alert("Please attach the requested form before submitting.");
return false;
}
return true;
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-22-2016 01:52 PM
Hi pradeep,
I have a requirement of adding recently uploaded attachment to email notification. Do you have any idea about how to query sys_attachment table to get recent attachment.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-16-2016 10:14 PM
Hello Pradeep,
I am using your script in Service portal.
Its now working,it not allowing me to submit the form,always populating the message,
Thanks
Saranya
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-17-2016 05:30 AM
This is a limitation of service-portal. When you upload an attachment, the attachment is always saved to the sp_portal table with an arbitrary sys_id. It is not until after the record is submitted and saved that the attachment moves to the correct table with the correct sys_id, so it will be difficult to do validation against.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-03-2016 10:09 PM
Hi Pradeep,
this script is gud.
but i want to run this rule for everyone.
not only created by.