Hello All,
I’m trying to use codes taken in from GoogleSheets through WebService in my survey (as form a one-time reward for participants).
I have a working script pasted in Google’s AppsScript (after each time I go through a preview or another form of doing the survey, I see in my GoogleSheets that a code has been used - it’s getting marked as used; I’ve pasted the script’s code at the very end of this message).
My Survey Flow looks like this (link is correct ;) and the length is as it is now, it’s testing first :))...

And I believe that piping in form is also fine:

However, I don’t see the code - just the text (even though the script works). I set the app as public with access to everyone and I’ve set the sheet as public (same; the app works in incognito and the test Web Service in Qualtrics’ Survey Flow connects with the app, marking new codes as used).
Still - there’s no code visible in either preview or actual link :(
Could anyone help me out and either point out what I’m doing wrong (and what I should do differently ;))?
Thanks a lot!
Kind regards,
M.
function doGet() {
var sheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Codes");
var data = sheet.getDataRange().getValues();
for (var i = 1; i < data.length; i++) {
if (data[i][1] === false) {
sheet.getRange(i + 1, 2).setValue(true); // Mark as used
return ContentService.createTextOutput(data[i][0]);setMimeType(ContentService.MimeType.TEXT);
}
}
return ContentService.createTextOutput("NO_CODES_LEFT");
}