- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-10-2024 08:29 AM
Hello, everyone.
I tested the identical set of scripts from the script background and was given a list of results (which is correct)
However, when the same script is used in script include, it just returns only the first line.
What might have gone wrong?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-10-2024 09:02 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-10-2024 09:02 AM
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