how to check if attachments are added before submitting the RITM?

saranyavs
Tera Expert

How to check if attachments are added to the catalog item before submitting the Request?

 

Regards,

Saranya

 

7 REPLIES 7

Vishnu-K
Tera Guru

Hi @saranyavs ,

You can write an onSubmit Client script for it .
code:

function onSubmit() {
// Check attachment count using GlideRecord
var attachment = new GlideRecord('sys_attachment');
attachment.addQuery('table_sys_id', g_form.getUniqueValue()); // RITM sys_id
attachment.query();

if (!attachment.next()) {
alert('Please attach a file before submitting.');
return false;
}
return true;
}


If this answers your question, please mark it as helpful and accept the solution for better community visibility.

 

Thanks,

Vishnu

I tried this method, but 'g_form.getUniqueValue()' is the sys id of item, not the RITM. so code is not working.

 

Utpal Dutta
Tera Guru

Hi @saranyavs ,

Just make attachment mandtaory by configuring the catalog item. 

 

If you're taking about making attachment type of variable mandatory then use UI policy to make attachment variable mandtaory.

 

If my answer helps then please mark it helpful & accept this solution.

 

Thanks,

Utpal

yashkamde
Tera Guru

Hello @saranyavs ,

 

For checking the attachments are added/mandatory just check the checkbox in catalog item form section :

Screenshot 2026-02-13 171221.png

 

If my response helped mark as helpful and accept the solution.