Script include return only one line

tsoct
Tera Guru

Hello, everyone.
I tested the identical set of scripts from the script background and was given a list of results (which is correct)

tsoct_0-1720625242062.png

 

However, when the same script is used in script include, it just returns only the first line.

tsoct_1-1720625341686.png

 

What might have gone wrong?

1 ACCEPTED SOLUTION

Robbie
Kilo Patron
Kilo Patron

Hi @tsoct,

 

If you want to return multiple data points from the Script Include, within your script include you'll need create an array to store the multiple values, then load the value for each pass of the loop, and then return this array (which is storing the multiple values).

 

Script Include syntax similar to the below:

var answers = []; //Creates the array and placeholder

 

Within you loop where you are currently attempting to print the result using gs.info(answer) - load into the array for each pass:

answers.push(answer);

 

Where you return in the Script Include:

return answers.toString();

 

Then, from within your Client Script which is calling the Script Include, you'll need something similar to the below:

 

var answers = [];

function returnValues(response){
        var answer = response; 
	alert("Answer: " + answer);
	answers=answer.split(",");
}

 

To help others (or for me to help you more directly), please mark this response correct by clicking on Accept as Solution and/or Kudos.


Thanks, Robbie

View solution in original post

5 REPLIES 5

Robbie
Kilo Patron
Kilo Patron

Hi @tsoct,

 

If you want to return multiple data points from the Script Include, within your script include you'll need create an array to store the multiple values, then load the value for each pass of the loop, and then return this array (which is storing the multiple values).

 

Script Include syntax similar to the below:

var answers = []; //Creates the array and placeholder

 

Within you loop where you are currently attempting to print the result using gs.info(answer) - load into the array for each pass:

answers.push(answer);

 

Where you return in the Script Include:

return answers.toString();

 

Then, from within your Client Script which is calling the Script Include, you'll need something similar to the below:

 

var answers = [];

function returnValues(response){
        var answer = response; 
	alert("Answer: " + answer);
	answers=answer.split(",");
}

 

To help others (or for me to help you more directly), please mark this response correct by clicking on Accept as Solution and/or Kudos.


Thanks, Robbie