
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-04-2018 10:30 AM
Hello Developers,
I need to output the result of a serverside script that i have written to use in the next step of ATF. the result of the script is a string which looks something like this "/api/now/table/incident/e1ce0900dbc123c075dd9837db961968". Please take a look at script and let me know how the variable "jsonresult_response" needs to be passed to the next step.
Thanks.
(function(outputs, steps, stepResult, assertEqual) {
var jsonresult_response;
var record_id;
var res= new GlideRecord("sys_atf_test_result_item");
res.addQuery('step','2f927cc8db41e3c4af4df35aaf96191c');
res.orderByDesc("sys_updated_on");
res.setLimit(1);
res.query();
while(res.next()) {
var jsonresult=res.output;
var startindex = jsonresult.indexOf("/api/now/table/incident/");
var endindex = jsonresult.indexOf("Cache-control");
jsonresult_response=jsonresult.substring(startindex,endindex);
outputs.record_id=jsonresult_response;
gs.info("output is "+outputs.record_id);
}
})(outputs, steps, stepResult, assertEqual);
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-04-2018 08:28 PM
Hi Sree
The max length of record_id is 32 characters as it represents sys_id. You should ideally create a new output variable under the step configuration 'Run Server Side Script'.
If there is a limitation to do this and you are bound to use OOB output variables, you can use the variable 'table' instead of 'record_id'. The max length of 'table' is 80 characters.
P.S. Please mark helpful/correct if appropriate to help others identifying the most relevant answer.
--
Best regards
Ankush
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-02-2019 07:59 AM
Thank you Ankush,
That's exactly what I was looking for. Right on dot. Excellent.
Thanks,
Rajan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-29-2024 09:33 AM
Could you please look into below post , Thanks in advance.
ATF Custom Step Query - ServiceNow Community

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-29-2024 09:59 AM
Done @YASIN SHAIK2