Completely new to scripts, would really appreciate some advice

26 views
Skip to first unread message

Dean Asbury

unread,
Aug 24, 2022, 4:26:37 AM8/24/22
to Google Apps Script Community
Hi Everyone,

I've been looking everywhere for a solution so maybe someone here can help.

I'm a marketer and not a developer but would like to put an alert up on Google Sheets whenever someone comes onto a shared sheet warning them about a certain action.

I found some code on youtube for this but it does not show when I open the sheet: 

function myFunction() {
  
  const ui = SpreadsheetApp.getUi();
  const html = HtmlService.createHtmlOutput('<p>This interface was written in HTML!</p>');

  ui.alert("DON'T EVEN THINK ABOUT IT!", "If you are unhiding rows make sure you hide them after, if not I will find you!", ui.ButtonSet.OK);
}

Any help here is greatly appreciated. 

Many Thanks

Clark Lind

unread,
Aug 24, 2022, 7:11:55 AM8/24/22
to Google Apps Script Community
You will need to add an onOpen() function that then calls your alert function.  

function onOpen() {
   myFunction()
}

function myFunction() {
  
  const ui = SpreadsheetApp.getUi();
  const html = HtmlService.createHtmlOutput('<p>This interface was written in HTML!</p>');

  ui.alert("DON'T EVEN THINK ABOUT IT!", "If you are unhiding rows make sure you hide them after, if not I will find you!", ui.ButtonSet.OK);
}

If the above doesn't run automatically run for everyone, then you will have to manually add a trigger.
Reply all
Reply to author
Forward
0 new messages