Delete multiple form response

707 views
Skip to first unread message

james cui

unread,
Aug 6, 2022, 1:45:01 AM8/6/22
to google-apps-sc...@googlegroups.com
Hey guys,

I am trying to delete multiple form responses using an app script. 
However, there seems to be a non-batch interface which only allows the deletion of a single response each time. It seems promising after looking at restful api for forms (https://developers.google.com/forms/api/reference/rest/v1/forms/batchUpdate), but I couldn't make it work due to permission issues. Anyone tried to delete multiple form responses via restful API? 

Clark Lind

unread,
Aug 6, 2022, 7:44:27 AM8/6/22
to Google Apps Script Community
It doesn't appear possible. Even the batchUpdate you reference is for deleting items off of a form, not for removing responses. For the moment, I think you are stuck deleting responses one at a time. 
Unfortunately, it seems Google Forms has been the laggard of the bunch to get Apps Script integration and support. 
One thought that just occurred to me is you might be able to include a webapp portion in your script with a published url. Then instead of having to make a bazillion REST calls, you could simply pass an object containing the response IDs to the webapp, and it could then iterate over it and run like a regular Apps script on the backend. So instead of a typical doGet() function, you would use a doPost() function that receives your object, and you could use a REST-like HTTP POST request to the published URL. Then iterate over the object and delete each item one by one. --I hope that makes sense.. I'm thinking as I type, and since you are already familiar with REST, I'm guessing the above makes sense to you.

james cui

unread,
Aug 6, 2022, 11:36:08 AM8/6/22
to google-apps-sc...@googlegroups.com
Thanks Clark, is your idea more like execute multiple single response delete call in an asynchronous way instead of delete one by one in a single api call?

--
You received this message because you are subscribed to the Google Groups "Google Apps Script Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-script-c...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-apps-script-community/e964983c-be11-4540-bea6-1700c9ca4698n%40googlegroups.com.

Clark Lind

unread,
Aug 8, 2022, 10:39:12 AM8/8/22
to Google Apps Script Community
Whatever object you send to the published url will have to be parsed anyway to get the info you need (hopefully responseIDs). Then yes, iterate over that list deleting each form response. At least it will be happening on the Google backend servers, so should go relatively quickly I would think. 
Reply all
Reply to author
Forward
0 new messages