hideSheet() being executed, but not actually hiding the sheet

Multi tool use
Multi tool use

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP



hideSheet() being executed, but not actually hiding the sheet



I am running this function i made in Google Apps Script for a spreadsheet add-on. It does everything right, but every OTHER execution it doesn't hide the sheet. Any ideas?


function addEmailNew(formObject)
var newEmail = formObject.addEmailText;
var ss = SpreadsheetApp.getActiveSpreadsheet();
ss.getSheetByName("No Touching!").activate();

//find the last string value in a column
var Avals = ss.getRange("J:J").getValues();
var Alast = Avals.filter(String).length + 1;
ss.getSheetByName('No Touching!').getRange("J" + Alast).setValue(newEmail);

//THIS IS THE THING THAT WORKS EVERY OTHER TIME
SpreadsheetApp.getActiveSheet().hideSheet();

openDialog();
return Logger.log("this did stuff");




1 Answer
1



It's fine to get the active sheet, but prior to hide it, activate another sheet. Try something like the following:


var sheetToHide = SpreadsheetApp.getActiveSheet();
ss.getSheetByName("Other sheet").activate();
sheetToHide.hideSheet();



If the problem persists, add SpreadsheetApp.flush(); on a new line after hideSheet().


SpreadsheetApp.flush();


hideSheet()





Thanks for the help Ruben. Sadly neither activating another sheet nor putting in the flush method worked :(
– Douglas Fordham
Aug 6 at 16:07






By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

t,ewR1TT8h vbb60E,mh,5J3ytSblXtev1XoxpMgtnGVvC,aKt,VP v0Y8SAQGg C aa9,eC3KKn5eA9uFWymoqC5 E rotRk
hRAj1lTQOG2ikLdX1o XIzaP9u2kymA,lhvi6oXuVUIp8zONGSx1OBTR 6N,0CzVrRbNZh 3n5 l1,Bv8f,ZcrH p,XRboSuVMacm q

Popular posts from this blog

Firebase Auth - with Email and Password - Check user already registered

Dynamically update html content plain JS

Store custom data using WC_Cart add_to_cart() method in Woocommerce 3