Now i have a number of seats for some trip and guests reserve their seats by filling a reservation form so i want to. decrease number of seats by rach reservation dynamically using app script code Execuse my english thanks in advance
Asked
Active
Viewed 27 times
-4
-
Welcome to StackOverflow. Please read and follow the posting guidelines in the [help documentation](http://stackoverflow.com/help/how-to-ask) . StackOverflow is not a design, coding, research, or tutorial service. – Pierre-Marie Richard Apr 10 '18 at 14:42
1 Answers
0
I think this is the kind of thing you'll want to play with.
//assuming form returns number of seats reseved as SeatsReserved in namedValues object.
function onFormSubmit(e){
var lock=LockService.getScriptLock();
var rs=Number(PropertiesService.getScriptProperties().getProperty('RemainSeats'));
var remainingSeats=rs-e.namedValues.SeatsReserved;
PropertiesService.getScriptProperties().setProperty('RemainingSeats', remainingSeats);
lock.releaseLock();
}
And you'll need to be able to initialize RemainSeats
function initSeats(s){
PropertiesService.getScriptProperties().setProperty('RemainSeats', s);
}
Note I haven't tested this, so write your own but now you know to look up ProptiesService, LockService and check out namedValues in the reference on Event Objects for Spreadsheets. Have fun.

Cooper
- 59,616
- 6
- 23
- 54