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
Giga Sage

Hello,

 

You can create a Display --> BR 

RaviGaurav_0-1724250512948.png

 

and use client like below :-

 

RaviGaurav_1-1724250645268.png

 

 

 

 

--------------------------------------------------------------------------------------------------------------------------


If you found my response helpful, I would greatly appreciate it if you could mark it as "Accepted Solution" and "Helpful."
Your support not only benefits the community but also encourages me to continue assisting. Thank you so much!

Thanks and Regards
Ravi Gaurav | ServiceNow MVP 2025,2024 | ServiceNow Practice Lead | Solution Architect
CGI
M.Tech in Data Science & AI

ï”— YouTube: https://www.youtube.com/@learnservicenowwithravi
ï”— LinkedIn: https://www.linkedin.com/in/ravi-gaurav-a67542aa/

View solution in original post

Ravi Gaurav
Giga Sage
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

--------------------------------------------------------------------------------------------------------------------------


If you found my response helpful, I would greatly appreciate it if you could mark it as "Accepted Solution" and "Helpful."
Your support not only benefits the community but also encourages me to continue assisting. Thank you so much!

Thanks and Regards
Ravi Gaurav | ServiceNow MVP 2025,2024 | ServiceNow Practice Lead | Solution Architect
CGI
M.Tech in Data Science & AI

ï”— YouTube: https://www.youtube.com/@learnservicenowwithravi
ï”— LinkedIn: https://www.linkedin.com/in/ravi-gaurav-a67542aa/

View solution in original post

2 REPLIES 2

Ravi Gaurav
Giga Sage
Giga Sage

Hello,

 

You can create a Display --> BR 

RaviGaurav_0-1724250512948.png

 

and use client like below :-

 

RaviGaurav_1-1724250645268.png

 

 

 

 

--------------------------------------------------------------------------------------------------------------------------


If you found my response helpful, I would greatly appreciate it if you could mark it as "Accepted Solution" and "Helpful."
Your support not only benefits the community but also encourages me to continue assisting. Thank you so much!

Thanks and Regards
Ravi Gaurav | ServiceNow MVP 2025,2024 | ServiceNow Practice Lead | Solution Architect
CGI
M.Tech in Data Science & AI

ï”— YouTube: https://www.youtube.com/@learnservicenowwithravi
ï”— LinkedIn: https://www.linkedin.com/in/ravi-gaurav-a67542aa/

Ravi Gaurav
Giga Sage
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

--------------------------------------------------------------------------------------------------------------------------


If you found my response helpful, I would greatly appreciate it if you could mark it as "Accepted Solution" and "Helpful."
Your support not only benefits the community but also encourages me to continue assisting. Thank you so much!

Thanks and Regards
Ravi Gaurav | ServiceNow MVP 2025,2024 | ServiceNow Practice Lead | Solution Architect
CGI
M.Tech in Data Science & AI

ï”— YouTube: https://www.youtube.com/@learnservicenowwithravi
ï”— LinkedIn: https://www.linkedin.com/in/ravi-gaurav-a67542aa/