How to add attachment by using ATF?

Geet Rana
Giga Contributor

I am searching for a way to add an attachment using ATF. This is the script I have used  :

(function(outputs, steps, stepResult, assertEqual) {
// add test script here
var t = steps('5311cd384fdd1bc4e72f029d0210c777').record_id; //sys_id of the change request
var ga= new GlideRecord('sys_attachment');
ga.initialize();
ga.file_name = 'test_attachment';
ga.content_type='image/jpeg';
ga.table_name = 'change_request';
ga.table_sys_id = t ;
outputs.table = 'sys_attachment';
outputs.record_id = ga.insert();


})(outputs, steps, stepResult, assertEqual);

I don't know how to add content in the attachment. In the change form this attachment is getting added so further steps are fine too, but there is no content.

2 REPLIES 2

rlatorre
Kilo Sage

My company is also looking for this functionality within ATF. Has anyone been successful adding an attachment as an ATF step?

Monmita Choudhu
ServiceNow Employee
ServiceNow Employee

Hi,

We have new steps to support the following cases in the New York release:

  •  Form - Add Attachments to Form
  •  Server - Add Attachments to Existing Record

https://docs.servicenow.com/bundle/newyork-application-development/page/administer/auto-test-framewo...