Use the Apps Script Lock Service to control Form submissions and prevent data loss
The following Google Apps Script is a one example of how the Lock Service can be used to prevent concurrent running of code. Here we have a Google Form that can be submitted by users at any point, the code then takes some of those details and appends them to another Google Sheet row. In normal circumstances this will happen relatively quickly and without clashes, but what if multiple people submit the Form at the same time!?
[Editor note: An alternative approach to
waitLock(). The only different with a
waitLock() is it will throw an exception after the set number of milliseconds. An example of
onFormSubmit is included in the reference documentation]
I use Google Apps Script to support staff and students in my job. I enjoy dabbling with creating tools to help with automation and I freely share my learning experiences on my blog, where I also have a number of useful Google Add-ons: www.pbainbridge.co.uk