[Help] Attachment testing ATF

Jordan14
Giga Expert

Hello,

I'm currently using the ATF module to test my incident forms and I would like to test the "manage attachments" area.

However, when I go to add a test step I can't to find the option which allows me to do this.

Any ideas?

Here's a screenshot of the "manage attachments" tab:

attachments tab.png

Kind Regards,

Jordan

6 REPLIES 6

Brad Tilton
ServiceNow Employee
ServiceNow Employee

Hi Jordan,



I don't believe the ATF currently supports testing adding an attachment so you wouldn't find it in the test form steps.



Automated test form steps


Thought so,



Guess they can include that in London .


Duncan Pederse1
Giga Expert

You can test adding attachments. You just need to have steps for inserting the Parent attachment record into the sys_attachment table, and the Child attachment byte data records into the sys_attachment_doc table.

srinivasthelu
Tera Guru

Create a New Step configuration. 

 

Step Environment : UI (There is a soft limitation) from the UI but.. 

 

 

(function executeStep(step, stepResult) {

var MESSAGE_KEY_UNABLE_TO_ADD_ATTACHMENTS = "FAILURE: Unable to add attachments";
var MESSAGE_KEY_FAILED_NO_G_FORM = "FAILURE: Unable to set values, g_form is not defined. A valid form must be open before setting values";
var MESSAGE_KEY_SUCCESSFULL = "SUCCESS:Successfully added attachments";

function passStep() {
stepResult.message = MESSAGE_KEY_SUCCESSFULL;
stepResult.success = true;
step.defer.resolve();
}

function failStep(reason) {
stepResult.message = reason;
stepResult.success = false;
step.defer.reject();
}


var testFrameWindow = g_ui_testing_util.getTestIFrameWindow();
if (!testFrameWindow.g_form) {
failStep(MESSAGE_KEY_FAILED_NO_G_FORM);
return;
}


var scope = testFrameWindow.angular.element("#sc_cat_item").scope();

var ga = new GlideAjax('Util');
ga.addParam('sysparm_name', 'copyAttachments');
ga.addParam('step_id', step.sys_id);
ga.addParam('item_id', scope.data._generatedItemGUID);
ga.getXMLWait();

var answer = ga.getAnswer();
testFrameWindow.alert(answer);
scope.attachments= JSON.parse(answer);

scope.setFocusToAttachment();
scope.$apply();


passStep();

}(step, stepResult));

 

Client Callabale Script Include : 

 

var Util = Class.create();
Util.prototype = Object.extendsObject(AbstractAjaxProcessor, {

copyAttachments: function (){
var step_id = this.getParameter('step_id');
var payroll_id = this.getParameter('item_id');
var answer = [];
GlideSysAttachment.copy('x_uxck3_payroll_request', payroll_id, 'sys_atf_step', step_id);

var gr = new GlideRecord('sys_attachment');
gr.addQuery('table_name', 'sys_atf_step');
gr.addQuery('table_sys_id', step_id);
gr.query();
while(gr.next()){
answer.push({
'file_name' : gr.file_name+'',
'sys_id' : gr.sys_id+''

});
}
return JSON.stringify(answer);

},

type: 'Util'
});