Not a *total* beginner but looking for help please with a G Sheets script.
I'm developing a "Job sheet" for a community repair shop. Buttons will allow the user to Add, Edit, Archive jobs.
I have functions for each operation, and an onEdit(e) function which verifies and carries out housekeeping for each operation.
onEdit(e) needs to know which operation is being done, and my first attempt was a global variable state which was set by the originating function and tested later by the onEdit function.
That didn't work (it always tested as 'IDLE', my initial state. Some research showed people had success with the Properties class/services. This isn't working either!
Some snippets:
This is outside all the functions:
var userProperties = PropertiesService.getUserProperties();
userProperties.setProperty('state', 'IDLE');
A button function:
function addJob() {
userProperties.setProperty('state', 'ADD');
I have checked that it is set properly using:
let state = userProperties.getProperty('state');
ui.alert('State: '+state);
onEdit function:function onEdit(e){
let state = userProperties.getProperty('state');
This shows state as IDLE!
I'd appreciate any help, thanks.