Very new to GAS but really enjoying getting to know how to customize Google Sheets for our sales team so they can generate project pricing out in the field using a tablet. Any help would be greatly appreciated.
I am currently using the following script along with helper columns to hide/unhide rows in a sheet that we use as an intake form to gather measurements and specs for roof replacement project (method found here - https://productforums.google.com/forum/#!topic/docs/PnDxvRfDZ7A;context-place=topicsearchin/docs/authorid$3AAPn2wQcI1gyAZ6TGNLNixhJidWO7WxTAnkDDZmrnn18VK7N4DRU2VZKQwGG_XClrBImjg06chA6H%7Csort:date%7Cspell:false)
function onEdit(e) {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var s = ss.getSheetByName("Shingle Roof Intake Form");
var row = s.getRange('A:A').getValues();
s.showRows(1, s.getMaxRows());
for(var i=0; i< row.length; i++){ if(row[i] == 'hide') { s.hideRows(i+1, 1); }
else if(row[i] == 'unhide'){ s.unhideRow(ss.getDataRange()); }
}}
I am using a variation of this same code along with helper columns to hide rows on another sheet we use to calculate our cost on said roofing projects (the auto hide rule only hides rows where total material and labor cost equal zero)
function onOpen(e) {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var s = ss.getSheetByName("Newman Costs");
var row = s.getRange('A:A').getValues();
s.showRows(1, s.getMaxRows());
for(var i=0; i< row.length; i++){ if(row[i] == 'hide') { s.hideRows(i+1, 1); }
}}
Both scripts are working and hiding rows based on other selections or edits, but the problem I'm having is that the script seems to run over and over each time a change or edit is made which makes the hidden rows reappear then hide again. Waiting on the script to run is holding things up so we'd like to avoid that if possible.
I've tried modifying the scripts based on information I was able to find while researching my issue, but no luck so far. Open to suggestions on editing the current script or using something different. Thank you in advance!