Mandatory attachment on close of catalog task?

robpresland
Tera Guru

I need to ensure there's an attachment to a catalog task, before the task is closed. I know I can make it mandatory with a Catalog UI Script, however this is not appropriate because I need to allow the fulfiller to update the catalog task during fulfillment and the attachment may not be available until after some of these updates.

I'd rather not use (say) a business rule if it needs to refer to a catalog task by Short Description as this is not reliable long-term; I'd like to find something within the catalog item if possible.

I saw something about a Client Script using ajax, but not too familiar with this. Is there a simpler option that runs on the server?

Thanks in advance.

1 ACCEPTED SOLUTION

Actually I was able to use a catalog client script I found in the community. I could probably reduce the 10 minutes to less as it's possible the user could submit more than one RITM within 10 mins, each with an attachment. I also found a script that finds attachments and sorts them by created_on in reverse, but I wasn't able to get that one to work.

 

function onSubmit() {
var grAtt = new GlideRecord("sys_attachment");
grAtt.addQuery("table_name", "sc_cart_item");
grAtt.addQuery("sys_created_by", g_user.userName);
grAtt.addQuery("sys_created_on", '>=', 'javascript:gs.minutesAgo(10)');
grAtt.query();
if (!grAtt.next()) {
alert("You must attach a vendor quote to submit this request");
return false;
}
return true;
}

View solution in original post

4 REPLIES 4

Sumanth16
Kilo Patron

Hi,

 

Can you please check below link:

https://community.servicenow.com/community?id=community_question&sys_id=d0febee5db58dbc01dcaf3231f96196d

 

In this business rule you can add that closed complete condition.

 

Thanks,

Sumanth

Thanks but I don't think that will work because I have two tasks as part of the RITM and the attachment is only required on close of the second task, so the criteria has to be task specific not RITM or CATITEM specific. Am I missing something in your suggested solution?

Then you have to create script includes and client script to achieve this.

 

 

Thanks ,

Sumanth 

Actually I was able to use a catalog client script I found in the community. I could probably reduce the 10 minutes to less as it's possible the user could submit more than one RITM within 10 mins, each with an attachment. I also found a script that finds attachments and sorts them by created_on in reverse, but I wasn't able to get that one to work.

 

function onSubmit() {
var grAtt = new GlideRecord("sys_attachment");
grAtt.addQuery("table_name", "sc_cart_item");
grAtt.addQuery("sys_created_by", g_user.userName);
grAtt.addQuery("sys_created_on", '>=', 'javascript:gs.minutesAgo(10)');
grAtt.query();
if (!grAtt.next()) {
alert("You must attach a vendor quote to submit this request");
return false;
}
return true;
}