How to run a script within ATF.

VIKAS MISHRA
Tera Contributor

Manually i can use the background script to run the below mentioned script and update a particular field value, However now wants to know how can i run below mentioned script to update a field value within ATF. 

Script:

var gr = new GlideRecord('x_amex_sourcing_request_request');
gr.addQuery('number', SRCENG0036058);
gr.query();
if(gr.next()){
gr.x_amex_sr_si_service_description = 'Testing by vikas';
gr.update();
}

14 REPLIES 14

Here you can see the step no. 34 which i have created for  the script that i am writting to update the field value.

 

find_real_file.png

so which record you are inserting?

which step is that?

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

It is step no. 34 "run server script" that i am using to update one of the field's value.

Below i have attached the screenshot of that step and the script that i am using there.

 

find_real_file.png

Hi,

line 81,82, 86 not required

also give the step sysId which has that record

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Hi Ankur,

This still not working we have tried below mentioned code there but its doing nothing.

Could you please confirm if this is actually possible or not i mean to update the field value as we can do through background script.

(function(outputs, steps, stepResult, assertEqual) {
var gr = new GlideRecord('x_amex_sourcing_request_request');
//gr.addQuery('sys_id','de8cace91beb8d106f82ca6b234bcb9d');
//gr.get(steps('sys_id').first_record);
gr.get(steps('39f955d31b0f81906f82ca6b234bcb48').record_id);
//gr.addQuery('sys_id','39f955d31b0f81906f82ca6b234bcb48');
gr.query();
if(gr.next()){
gr.x_amex_sr_si_service_description = 'Testing by vikas000';

gr.update();
}