Editing Form Responses Programmatically - google-apps-script

I have a google script that generates the edit URLs for each form response that is dumped into my spreadsheet. Is there a way to programatically change the response values as if I had actually opened the URL and changed the values manually?
For example, suppose someone submitted a form with the name field being "Sam." I want to be able to programmatically edit this response so that the value of the same field is "Samuel."
This is very easy to do manually via the form response edit url, however I am running into issues trying to do this in my scripts.

Related

In constructing a Google Form dropdown is it possible for the response that gets stored to be a coded value of what the user chooses?

In my Google Form I want to show the user a dropdown list consisting of several values from which he can choose one value. Such as:
Guernsey
Hereford
Jersey
But when his response gets stored into the response sheet I want it to be stored as a corresponding coded value, such as:
301
371
422
Is there any way to do this when I build a Form? Can it be accomplished with Google App Script?
Google Forms doesn't include form responses codification and the built-in feature that send form responses to an spreadsheet either. One alternative is that you use on form summit installable trigger. There are one for scripts bounded to forms and another for scripts bounded to spreasheet, each one having their own event object. For details see https://developers.google.com/apps-script/guides/triggers/events.

Make a new response from an existing Google Form response

I have studied this question and found it helpful:
How do I edit the response of a form submission in Google Forms/Sheets?
Now I would like to take it a step further. Once I have the editable response URL, I notice that when I go to the URL and edit and submit the response, it modifies the original response line in the sheet.
What if, instead of modifying, I want to make a NEW response. That is, upon editing, when I Submit, the set of responses makes a NEW row in the spreadsheet. I'm trying to think of a way I can do this, but not coming up with anything. Any ideas?

Editing a google doc form submission?

I submitted a response to a google form I was sent. I had the option to edit it afterwards however I didn't save the URL.
Is there anyway to find the URL or to edit my submission?
It is possible to get the edit response URL on submission.* (And have it written to a sheet, or emailed.)
In your case however, if you want to edit your previous response you can go to the form using the same url. (If it is limited to one response, you should have an option to edit your response.)
Using Google App Script

How can I load one google spreadsheet cell with a value obtained from a remote JSON request?

I want to populate a google spreadsheed cell with values that I obtain by making JSON HTTP requests to other servers.
If this can be done on schedule even better but even I can trigger this using a simple button on the spreadsheet is ok.
Example of url: https://review.openstack.org/changes/621517 which return a JSON object, and I want to save the status attribute in one cell.
I don't want to write a local script that does this update and updates the spreadsheet as I prefer to make this part of the spreadsheet itself via Script Editor.
For your example, the following should return NEW:
=substitute(REGEXEXTRACT(index(IMPORTDATA("https://review.openstack.org/changes/621517"),10,1),""".*?"""),"""","")

Use Apps Script to change the response of a single form item directly (programmatically) rather than using the edit response urlj

I am using a form to collect booking details and have the script attached to the form (so that the form submit trigger will trigger when the response is edited, which the spreadsheet bound version does not allow) which sends an email, schedules calendar events, creates confirmation documents etc on form submit. Using if statements I have provided the user the ability to avoid 'click the box to not send the customer an email on submit' functionality so that the form responses can be edited without triggers the automated functions, but that relies on the user remembering to click those boxes.
A better solution would be to be able to have the script, as its final function, change the item response, so that when the form is edited in future, the automatic functions are already disabled.
I do not want to create a new form response (although it would be possible to tweak the pre-populated url to create a duplicate with the appropriate changes)
FormResponse.withItemResponse(response) specifies that it doesn't work on stored responses
It is so easy to view form responses, and with the native edit response url functionality I figured editing a single item response would be doable, but so far it has eluded me.
Is there a way to do this?
Thanks
At this time Form responses could only be created programmatically, they can't be edited programmatically. Consider to submit a feature request through Google Apps Script Issues