<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>question Re: Outputs variable of ATF Serverside script in Developer forum</title>
    <link>https://www.servicenow.com/community/developer-forum/outputs-variable-of-atf-serverside-script/m-p/1441955#M98881</link>
    <description>&lt;P&gt;Thank you Ankush,&lt;/P&gt;
&lt;P&gt;That's exactly what I was looking for. Right on dot. Excellent.&lt;/P&gt;
&lt;P&gt;Thanks,&lt;/P&gt;
&lt;P&gt;Rajan&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sun, 02 Jun 2019 14:59:13 GMT</pubDate>
    <dc:creator>Rajanmehta</dc:creator>
    <dc:date>2019-06-02T14:59:13Z</dc:date>
    <item>
      <title>Outputs variable of ATF Serverside script</title>
      <link>https://www.servicenow.com/community/developer-forum/outputs-variable-of-atf-serverside-script/m-p/1441950#M98876</link>
      <description>&lt;P&gt;Hello Developers,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;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.&lt;/P&gt;
&lt;P&gt;Thanks.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE class="language-javascript"&gt;&lt;CODE&gt;(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);

&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 04 Oct 2018 17:30:32 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/outputs-variable-of-atf-serverside-script/m-p/1441950#M98876</guid>
      <dc:creator>Nitesh Balusu</dc:creator>
      <dc:date>2018-10-04T17:30:32Z</dc:date>
    </item>
    <item>
      <title>Re: Outputs variable of ATF Serverside script</title>
      <link>https://www.servicenow.com/community/developer-forum/outputs-variable-of-atf-serverside-script/m-p/1441951#M98877</link>
      <description>&lt;P&gt;Hi Sree&lt;/P&gt;
&lt;P&gt;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'.&lt;/P&gt;
&lt;P&gt;If there is&amp;nbsp;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.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;P.S. Please mark helpful/correct&amp;nbsp;if appropriate to help others identifying the most relevant answer.&lt;/P&gt;
&lt;P&gt;--&lt;/P&gt;
&lt;P&gt;Best regards&lt;/P&gt;
&lt;P&gt;Ankush&lt;/P&gt;</description>
      <pubDate>Fri, 05 Oct 2018 03:28:56 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/outputs-variable-of-atf-serverside-script/m-p/1441951#M98877</guid>
      <dc:creator>Ankush Agrawal</dc:creator>
      <dc:date>2018-10-05T03:28:56Z</dc:date>
    </item>
    <item>
      <title>Re: Outputs variable of ATF Serverside script</title>
      <link>https://www.servicenow.com/community/developer-forum/outputs-variable-of-atf-serverside-script/m-p/1441952#M98878</link>
      <description>&lt;P&gt;Got it! Thanks!&lt;/P&gt;</description>
      <pubDate>Fri, 05 Oct 2018 15:00:49 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/outputs-variable-of-atf-serverside-script/m-p/1441952#M98878</guid>
      <dc:creator>Nitesh Balusu</dc:creator>
      <dc:date>2018-10-05T15:00:49Z</dc:date>
    </item>
    <item>
      <title>Re: Outputs variable of ATF Serverside script</title>
      <link>https://www.servicenow.com/community/developer-forum/outputs-variable-of-atf-serverside-script/m-p/1441953#M98879</link>
      <description>&lt;P&gt;hi Ankush,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have similar requirement. Want to pass on out put of first step to next step.&lt;/P&gt;
&lt;P&gt;Can you please guide me how do I get this to pass on to next step? What do I need to do in next step?&lt;/P&gt;
&lt;P&gt;Please advise.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks,&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Step 1:&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;(function(outputs, steps, stepResult, assertEqual) {&lt;BR /&gt; // add test script here&lt;/P&gt;
&lt;P&gt;:&lt;/P&gt;
&lt;P&gt;:&lt;/P&gt;
&lt;P&gt;:&lt;/P&gt;
&lt;P&gt;var response = request.execute();&lt;BR /&gt; outputs = response.getBody(); &lt;BR /&gt;})(outputs, steps, stepResult, assertEqual);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Step 2:&lt;/P&gt;
&lt;P&gt;??? var output_Step1 = steps('xxxxxxxxxxxxxxxxxxxx').outputs ; // Passing sys_id of Step 1&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am not getting anything if I do this. Please advise.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks,&lt;/P&gt;
&lt;P&gt;Rajan Mehta&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 31 May 2019 22:50:50 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/outputs-variable-of-atf-serverside-script/m-p/1441953#M98879</guid>
      <dc:creator>Rajanmehta</dc:creator>
      <dc:date>2019-05-31T22:50:50Z</dc:date>
    </item>
    <item>
      <title>Re: Outputs variable of ATF Serverside script</title>
      <link>https://www.servicenow.com/community/developer-forum/outputs-variable-of-atf-serverside-script/m-p/1441954#M98880</link>
      <description>&lt;P&gt;Hi Rajan&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;There are 2 catches:&lt;/P&gt;
&lt;OL&gt;&lt;LI&gt;outputs is the returned object and the output variables are stored inside it, e.g.: outputs.record_id etc. Hence Step 1 should have the line as&lt;BR /&gt;outputs.record_id = response.getBody(); &lt;BR /&gt;&lt;BR /&gt;Similarly Step 2 should refer this as:&lt;BR /&gt;var output_Step1 = steps('xxxxxxxxxxxxxxxxxxxx').outputs.record_id;&lt;BR /&gt;&lt;BR /&gt;&lt;/LI&gt;&lt;LI&gt;I believe getBody might return a large JSON object. If yes, you can go to the step configuration 'Run Server Side Script' and create a new output variable there of type Name-Value Pair (say, u_json_output). This can store JSON string and set via outputs.u_json_output = response.getBody() and can be referred in subsequent steps as&lt;BR /&gt;&lt;BR /&gt;var output_Step1 = steps('xxxxxxxxxxxxxxxxxxxx').outputs.u_json_output;&lt;/LI&gt;&lt;/OL&gt;
&lt;P&gt;--&lt;BR /&gt;Best regards&lt;BR /&gt;Ankush&lt;/P&gt;
&lt;P&gt;P.S. Please mark helpful to help fellow Community user in identifying useful answers.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 02 Jun 2019 07:05:34 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/outputs-variable-of-atf-serverside-script/m-p/1441954#M98880</guid>
      <dc:creator>Ankush Agrawal</dc:creator>
      <dc:date>2019-06-02T07:05:34Z</dc:date>
    </item>
    <item>
      <title>Re: Outputs variable of ATF Serverside script</title>
      <link>https://www.servicenow.com/community/developer-forum/outputs-variable-of-atf-serverside-script/m-p/1441955#M98881</link>
      <description>&lt;P&gt;Thank you Ankush,&lt;/P&gt;
&lt;P&gt;That's exactly what I was looking for. Right on dot. Excellent.&lt;/P&gt;
&lt;P&gt;Thanks,&lt;/P&gt;
&lt;P&gt;Rajan&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 02 Jun 2019 14:59:13 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/outputs-variable-of-atf-serverside-script/m-p/1441955#M98881</guid>
      <dc:creator>Rajanmehta</dc:creator>
      <dc:date>2019-06-02T14:59:13Z</dc:date>
    </item>
    <item>
      <title>Re: Outputs variable of ATF Serverside script</title>
      <link>https://www.servicenow.com/community/developer-forum/outputs-variable-of-atf-serverside-script/m-p/2913203#M1109179</link>
      <description>&lt;P&gt;&lt;a href="https://www.servicenow.com/community/user/viewprofilepage/user-id/88634"&gt;@Ankush Agrawal&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Could you please look into below post , Thanks in advance.&amp;nbsp;&lt;/SPAN&gt;&lt;BR /&gt;&lt;A href="https://www.servicenow.com/community/developer-forum/atf-custom-step-query/td-p/2912335" target="_blank"&gt;ATF Custom Step Query - ServiceNow Community&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 29 Apr 2024 16:33:39 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/outputs-variable-of-atf-serverside-script/m-p/2913203#M1109179</guid>
      <dc:creator>Community Alums</dc:creator>
      <dc:date>2024-04-29T16:33:39Z</dc:date>
    </item>
    <item>
      <title>Re: Outputs variable of ATF Serverside script</title>
      <link>https://www.servicenow.com/community/developer-forum/outputs-variable-of-atf-serverside-script/m-p/2913222#M1109187</link>
      <description>&lt;P&gt;Done&amp;nbsp;@Community Alums&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 29 Apr 2024 16:59:32 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/outputs-variable-of-atf-serverside-script/m-p/2913222#M1109187</guid>
      <dc:creator>Ankush Agrawal</dc:creator>
      <dc:date>2024-04-29T16:59:32Z</dc:date>
    </item>
  </channel>
</rss>

