ATF - Run server side script not able to get the previous step Sys ID of the record
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-17-2020 01:18 PM
I have only 3 steps. 1)Impersonate(ITIL user) 2) log and 3) Run server side script.
There are only 1 parameters(parametrized test) 1) Group name: Change Management (referenced)
I am using 'log' as a step to pass on group Syd ID. (step sys-id and group sys-id) are fine and working alright.
Somehow the below in my script is not working. I tried all the list options.
This line is not working: grp_sysid = steps(last_step_sysid).record_id;
(function(outputs, steps, stepResult, assertEqual) {
var last_step_sysid = 'b048fd8c074788105e7efc289c1ed05c';
grp_sysid = steps(last_step_sysid).record_id;
//grp_sysid = 'a715cd759f2002002920bde8132e7018';
var gr = new GlideRecord('sys_user_group');
gr.get('sys_id', grp_sysid);
var theIDiwant = '';
theIDiwant = gr.name;
outputs.record_id = theIDiwant;
gs.log('***** Group name *******: ' + outputs.record_id);
gs.addInfoMessage(gr.name);
})(outputs, steps, stepResult, assertEqual);
I am seeing group name empty.
You may please try through a dev instance.
I appreciate any help. Thanks
- Labels:
-
Automated Test Framework

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-18-2020 05:41 PM
You can add log for gr.getRowCount() to see if you actually found any matching records BUT...
The Log test step has no output to pass on to other test steps from what I can tell so I don't think line this works:
grp_sysid = steps(last_step_sysid).record_id;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-23-2020 10:21 AM
Suresh,
Did you ever find out the answer to this? I'm having the same issue. I put in a hard-coded sys_id and then use the steps function but nothing is returned. See below excerpt.
What version are you using? We're in Orlando.
========== excerpt ==========
gs.sleep(30000); // Wait for tasks to get created
var requestSysId = 'f87c5252dbd0141065353533f396199b'; // output is request
var requestNumber = steps(requestSysId).record_id;
gs.info("request Sys ID: " + requestSysId);
gs.info("request number: " + requestNumber + '');
var gr = new GlideRecord('sc_task');
gr.addQuery('request', requestNumber);
gr.query();
=========================
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-23-2020 05:48 PM
@wpatrickhames
I replaced 'record_id' with 'first_record' and it worked. I made sure the first step is a 'record query' that fetches at least one record to pass it on to Step:2
Step:1 Record Query to get a request record
Step:2
gs.sleep(30000); // Wait for tasks to get created
var gr = new GlideRecord("sc_task");
var requestSysId = 'ca709666075850105e7efc289c1ed0fe'; // output is request
var requestNumber = steps(requestSysId).first_record;
gs.info("request Sys ID: " + requestSysId);
gs.info("request number: " + requestNumber + '');
outputs.record_id = gr.get('request', requestNumber);
assertEqual({
name: "task gr exists",
shouldbe: true,
value: gr.isValidRecord()
});
Step:3 Log record to check 'true'
Please see the test results attached.
Hope it helps.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-23-2020 10:57 PM
Thanks for the reply