Reset values daily

Looking to make a list of daily tasks that the user can check off in a checkmark component, and have the responses reset daily. Is this possible to do within glide or would I need to find a script to do this in Google Sheets?

Any leads are appreciated. Thanks!

I think you would need a script. It shouldn’t be that difficult, if you have any questions or need a start give us more details.

@George_B

Users are added when they register. I want to clear B2-E (?)**

*Depending on the number of users… I suppose the script could be written to clear to f2?

Here you go.

1 Like

Hi, how can I view this? Am a beginner and just wondering if I can borrow the code to clear a column too…

@simpler Just click the link. You should end up in View only mode. Go to File/Make a copy. Once that is open you can go to Tools/Script editor and look at the script. The script has only 3 functions. One that creates the menu item on open, another one to run the onOpen via the onInstall event. The one that resets the values that @Mr_Watkin needed is the third one. Here is a copy of the script, but you should be able to view it once you make your own copy of the spreadsheet.

/**
* Add-on menu with links to pull various data
*
* @param {Object} e The event parameter for a simple onOpen trigger.
*/

function onOpen(e) {
  var spreadsheet = SpreadsheetApp.getActive();
  var menuItems = [
    {name: 'Reset SlaveTasks', functionName: 'resetSlavetasks'},
  ];
  spreadsheet.addMenu('MrWatkin', menuItems);

}

/**
* Runs when the add-on is installed; calls onOpen() to ensure menu creation and
* any other initializion work is done immediately.
*
* @param {Object} e The event parameter for a simple onInstall trigger.
*/
function onInstall(e) {
  onOpen(e);
}

// create a trigger to run this function every night
function resetSlavetasks() {
  var ss = SpreadsheetApp.getActiveSpreadsheet(); // gets a spreadsheet reference
  var sheet = ss.getSheetByName("slavetasks"); // gets a sheet reference
  var range = sheet.getDataRange(); // gets the range of all data
  var data = range.getValues(); // puts all values of the sheet into an array
  
  // step through the array and reset all the values in rows 2 through the end for columns B, C, D, E
  for (var i = 1; i < data.length; i++) {
    data[i][1] = false;  // this is cell B2, the next loop it would be B3 and so on
    data[i][2] = false;  // this is cell C2, the next loop it would be C3 and so on
    data[i][3] = false;  // this is cell D2, the next loop it would be D3 and so on
    data[i][4] = false;  // this is cell E2, the next loop it would be E3 and so on
  }
    
  range.setValues(data);  // this writes back all the data to the sheet
}   

Thanks for the quick reply. I’ll have a look now.

Hi George, is there a way to re-use this script to do the following for shopping list:

eg. I note to buy 3 items and once I check it off, the 3 items are recorded in my pantry list for next time? And the to do list is cleared?

(I’m afraid I couldn’t run the script to see how this actually works)…

I’m not sure you would even need a script to do what you want to do. I would suggest that you watch at least 5 or 6 of @JackVaughan’s tutorials and build a few of the apps he walks you through step by step, if you haven’t done so already. Then create a document that has as much detail as you can think of about what you are trying to accomplish with the app you have in mind. The next step would be to create the spreadsheet that will hold the data that your app needs. Then create the app from that spreadsheet.

Hi, I have.

I created sheet with list of pantry items. When I note the quantity I want and then check them off once I buy them. I then want the quantity bought to be recorded that it’s in the pantry and the quantity cell is cleared for the next time. Any ideas? Jack’s videos doesn’t have it, I’ve watched them all…

I would suggest you need to create another sheet that pulls in any item from your main list that has a qty needed, your shopping list. Then you would add an additional column to that sheet that would hold the checkbox result. When at the store you would check off the items that you actually bought and when finished shopping you would run the script that would scan that shopping list sheet, and reset the quantities to buy in your master list, as well as add those items to the pantry list. It would be pretty involved as the script would have to look up if the pantry already had a quantity of that item in it and thus you would need to add the qty bought to the qty already one hand.

The pantry items list could have a column for how much is in the pantry, as well as how much you want to keep in the pantry. Then you could generate shopping lists based on what you have on hand vs. what you want to have. If you were to add things like what store you buy the item in and what are the standard case or package quantities that the items come in you could develop a comprehensive inventory management system.

Thanks George. I’ll try the second option. That might work! Thanks for the reply. I’m in Aust. so off to bed now:-)

Hi, I am making a simple calculator and would like to reset the values when a “Reset” button is clicked. Is there any way to do this in Glide or Google spreadsheets? Thanks in advance.

1 Like

I can’t think of any way to do it within Glide as there is no action that would write directly to a cells contents like this. Maybe someone else would have a workaround.

I see; I found a script that created a reset button in Google Sheets as an extension. https://support.google.com/docs/thread/5809954?hl=en
With this be at all helpful? If not, how would you recommend going about writing a script?

The only recommendation would be to look at a bunch of script writing tutorials and write one. Then 2, then 3, etc… Then keep writing them until you are confident that it does what you want. To simply clear a few columns is pretty straight forward. If you wanted to clear the contents of columns E and F on Sheet2, this is the script.

function clearAFewColumns() {
  var sheet = SpreadsheetApp.getActive().getSheetByName('Sheet2');
  var lastRow = sheet.getLastRow();
  
  // Column E = 5; F = 6   
  sheet.getRange(2, 5, lastRow, 1).clearContent();
  sheet.getRange(2, 6, lastRow, 1).clearContent();
  
}

Do some Google searches on how to add a Box on a sheet, or create a menu item, and have it execute a function.

hi, did you find a way to reset values?

I have a delivery app where the delivery driver checks off delivery orders made.

Is there a way to clear only the items that have been checked off in a spreadsheet? (daily)

I can only think of using script to clear values daily. Or create a row for each day and only filter to show the current day in the app so only the current day row gets updated.

Hi @George_B thank you very much for your code. At the moment, I am trying to adjust it a bit so that it fits my application (here’s the link, but it shouldn’t be necessary for the purpose of my question: https://idea-in-sight.glideapp.io/)

Contrarily to @Mr_Watkin, it does not matter to me how the table is populated with data, I just want to clear whatever happens to be there every midnight and I do not even want the backup. Does it mean that I can only use the third function in the form below? Which part of the script triggers the function? Can the time of reset be adjusted?

function resetSlavetasks() {
  var ss = SpreadsheetApp.getActiveSpreadsheet(); // gets a spreadsheet reference
  var sheet = ss.getSheetByName("slavetasks"); // gets a sheet reference
  var range = sheet.getDataRange(); // gets the range of all data
  var data = range.getValues(); // puts all values of the sheet into an array
  
  // step through the array and reset all the values in rows 2 through the end for columns B, C, D, E
  for (var i = 1; i < data.length; i++) {
    data[i][1] = false;  // this is cell B2, the next loop it would be B3 and so on
    data[i][2] = false;  // this is cell C2, the next loop it would be C3 and so on
    data[i][3] = false;  // this is cell D2, the next loop it would be D3 and so on
    data[i][4] = false;  // this is cell E2, the next loop it would be E3 and so on
  }

Thank you in advance. I am just a beginner with scripts.