I’m getting really frustrated with custom scripting. I can’t get anything to work, even simple things, and there seems to be virtually nothing in the way of troubleshooting.
For the script below, I’m just grabbing a selected item from a previous question, setting a hidden value to that item, and then mentioning it in a later question. The order is: previous question [page break] instruction page, script action, hidden value 1, hidden value 2 [page break] later question
Here’s the simple code:
//Grab two selected items from a chkbox question for follow-up and save
//in a couple of hidden value actions. A later question pulls from them.
// I’ve tried with both ID #s and question aliases. I’ve tried square brackets vs. curly braces.
%%selResps = sgapiGetValue(11);
%%selRespsArr = sgapiExplode(“,”,%%selResps);
%%output = %%selRespsArr;
The hidden values never get updated, so the later question that pulls them in via merge code displays only the default value.
I also am unable to display any %%output value, and if the how-to is in the documentation anywhere, it’s well-hidden.
Thanks in advance!
My name is Bri. I am the documentation coordinator at SurveyGizmo. I’m plugging away at improving the scripting documentation so your post is very timely.
When outputting arrays, you’ll need to use sgapiPrint_R in order to do so. You can see an example here:
Regarding Hidden Values, they have a tendency to hang on to their original value. In scripting if you are trying to reset a Hidden Value you’ll need to pair it with sgapiSubmitSurvey in order to do so. Here’s a quick example script:
//reset merge code
Hopefully this gets you over the hump!
SurveyGizmo Customer Experience Team