There are 2 patterns for retrieving submitted values. For both patterns, the function for retrieving the values from form submission has to be installed as a trigger. The detail information of Installable Triggers is https://developers.google.com/apps-script/guides/triggers/installable.
1. Script is opened on spreadsheet.
In this case, by installing a trigger, you can retrieve the submitted values by your script. The detail information of Event Objects is https://developers.google.com/apps-script/guides/triggers/events#form-submit.
Script :
function onSubmit(e){
Logger.log("%s", JSON.stringify(e));
}
Result :
{
"values": [
"date and time",
"test"
],
"namedValues": {
"fromtestform": [
"test"
],
"timeStamp": [
"date and time"
]
},
"range": {
"columnStart": 1,
"rowStart": 2,
"rowEnd": 2,
"columnEnd": 2
},
"source": {},
"authMode": {},
"triggerUid": #####
}
2. Script is opened on form.
In this case, the submitted values can be retrieved by following script. The detail information is https://developers.google.com/apps-script/reference/forms/form-response.
Script :
function onSubmit(e){
Logger.log("authMode=%s, source.getId()=%s", e.authMode, e.source.getId());
var items = e.response.getItemResponses();
for (i in items){
Logger.log("getItem().getTitle()=%s, getResponse()=%s", items[i].getItem().getTitle(), items[i].getResponse());
}
}
Result :
authMode=FULL, source.getId()=### form ID ###
getItem().getTitle()=## item's title ##, getResponse()=test
If I misunderstand your question, I’m sorry.