How to check whether Attachment is attached to the form or not.

SandeepKSingh
Kilo Sage

Hi Team ,

I need to check if attachment is atached to the form then Alert box should appear with attachment name .

How to achieve??

2 ACCEPTED SOLUTIONS

Ravi Gaurav
Giga Sage

Hello,

 

You can create a Display --> BR 

RaviGaurav_0-1724250512948.png

 

and use client like below :-

 

RaviGaurav_1-1724250645268.png

 

 

 

 

View solution in original post

Ravi Gaurav
Giga Sage

Try one more approach :-

 

function onSubmit() {
var attachmentNames = [];


var attachmentGR = new GlideRecord('sys_attachment');
attachmentGR.addQuery('table_sys_id', g_form.getUniqueValue());
attachmentGR.query();


while (attachmentGR.next()) {
attachmentNames.push(attachmentGR.getValue('file_name'));
}

if (attachmentNames.length > 0) {
alert('Attachments found: ' + attachmentNames.join(', '));
}

return true; // Allow the form to submit
}

try the above

View solution in original post

2 REPLIES 2

Ravi Gaurav
Giga Sage

Hello,

 

You can create a Display --> BR 

RaviGaurav_0-1724250512948.png

 

and use client like below :-

 

RaviGaurav_1-1724250645268.png

 

 

 

 

Ravi Gaurav
Giga Sage

Try one more approach :-

 

function onSubmit() {
var attachmentNames = [];


var attachmentGR = new GlideRecord('sys_attachment');
attachmentGR.addQuery('table_sys_id', g_form.getUniqueValue());
attachmentGR.query();


while (attachmentGR.next()) {
attachmentNames.push(attachmentGR.getValue('file_name'));
}

if (attachmentNames.length > 0) {
alert('Attachments found: ' + attachmentNames.join(', '));
}

return true; // Allow the form to submit
}

try the above