Welcome to Community Week 2025! Join us to learn, connect, and be recognized as we celebrate the spirit of Community and the power of AI. Get the details  

How to handle mandatory attachment field on a form in ATF?

Mayank Das3
Tera Contributor

Hello all

 

I have a custom attachment field on the change request form which I need to automate using ATF. How do I handle the mandatory attachment field using 'Set Field Values' step?

 

I have already tried to use 'Record Query' to query a random attachment on the 'sys_attachment' table but it does not allow me to refer on the 'Set Field Values' step.

 

Hard coding the sys_id of a random attachment on the field also did not work.

 

Please help!

MayankDas3_0-1762156404534.png

 

2 REPLIES 2

Ravi Gaurav
Giga Sage
Giga Sage

Hi @Mayank Das3 
To add a mandatory attachment in Automated Test Framework (ATF) for a form, you need to use a workaround since standard "mandatory" fields are not supported for attachments. A common approach is to use the "Add Attachment" step in the ATF, and on the form, use a client-side script or a business rule to enforce the attachment requirement before submission. 

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


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/

and follow the below thread
https://www.servicenow.com/community/developer-forum/how-to-add-attachment-to-a-mandatory-attachment...

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


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/