- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-14-2019 10:14 AM
Hello team,
I'm currently working on a test case in Automated Test Framework in the Discovery area.
I have a "Record Query" test step that returns a specific record from the discovery_device_history table. In the following step I execute some validations in the fields successfully.
In the following step, I have a Run Server Side Script test step that I want to get the CMDB CI value of the discovery_device_history record and use it as an Output - so in the next steps I can open and validate the CI record.
Here is my script:
(function(outputs, steps, stepResult, assertEqual) {
var sysIDstep1 = 'fakkeekkeekk773006d50f9baae961987'; //Step 1 Sys ID
var recordIDStep1 = steps(sysIDstep1).record_id;
var record_id;
outputs.table = 'cmdb_ci_linux_server';
outputs.record_id = recordIDStep1.cmdb_ci;
stepResult.setOutputMessage("Output: "+ sysIDstep1 + recordIDStep1 + record_id);
})(outputs, steps, stepResult, assertEqual);
My output:
Output: fakkeekkeekk773006d50f9baae961987undefinedundefined
Any suggestion of what I am doing wrong and how I can fix the script? So the CI becomes my output?
Thank you in advance.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-10-2019 02:01 PM
Hi Elijah
Sorry for the late response. Yes, I figured a way to do it! 🙂
(function(outputs, steps, stepResult, assertEqual) {
// Returns the server sys_id, using Step that has Device History as output
var recordIDStep10 = steps('SYS ID OF THE STEP').first_record;
// Gets the zOS server data/record
var queryString = "sys_id=" + recordIDStep10;
var request = new GlideRecord('discovery_device_history');
request.addEncodedQuery(queryString);
request.query();
var theIDIwant = '';
if (request.next()) {
theIDIwant = request.cmdb_ci;
} else {
// Doesn't exists a server - Failure
}
var record_id;
outputs.record_id = theIDIwant;
stepResult.setOutputMessage("SYSID: " + recordIDStep10 + " SYS ID of CI: " + theIDIwant);
})(outputs, steps, stepResult, assertEqual);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-15-2019 08:50 AM
Hi guys.
I managed to get a bit better, by having the Device sys_ID showing up in the Output message by using first_record instead of record_id. But still getting undefined for the CI.
Here is my updated code:
(function(outputs, steps, stepResult, assertEqual) {
var sysIDstep1 = 'fa66c5b0dbd773006d50f9baae961987'; //Step 1 Sys ID
var recordIDStep1 = steps(sysIDstep1).first_record;
var cmdbNumero = recordIDStep1.cmdb_ci;
var record_id;
outputs.table = 'cmdb_ci_linux_server';
outputs.record_id = cmdbNumero;
gs.log('body ' + record_id);
gs.log('body type' + (typeof record_id));
if (outputs.record_id) {
stepResult.setOutputMessage("sysIDstep1: "+ sysIDstep1 + " recordIDStep1: "+ recordIDStep1 + " cmdbnumero "+ cmdbNumero + "recordID" + record_id);
return true;
} else {
stepResult.setOutputMessage("Failed Step");
return false;
}
})(outputs, steps, stepResult, assertEqual);

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-16-2019 02:55 PM
Try replacing record_id with outputs.record_id in your stepOutputMessage.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-19-2019 09:43 AM
Hi Masha.
I tried that but still showed "undefined" in the results.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-29-2019 01:59 PM
Hi guys.
I'm still struggling with this, after attempting a few more changes.
Any ideas on how to solve this "undefined" issue?
I've been working with ATF for a while and it's very useful to me, but now I need to use the scripting steps to develop more advanced test cases and I can't pass this basic part of input/output.
Any help would be appreciated 🙂
Thank you.