2

I've created a spreadsheet in google drive, and I've put together a tutorial presentation using google presentations to demonstrate to the users how to use the spreadsheet and why it's better than the way we were doing it before.

What I would like is a message box to appear when the spreadsheet is opened asking if that person has watched the tutorial presentation yet. If the user clicks No I'd like to either open a new page in the browser to show them the presentation I've published, or show the presentation in a custom UI.

I've searched for hours and can't figure it out. Is this possible? Thank you for your help!

I'm new to the forum so please let me know if I posted this wrong. Thanks!

user2668584
  • 23
  • 1
  • 3
  • It is possible to do this using Apps Scripts (Hint: Use a UI panel with an Anchor in it). But it would help to state what you've already tried and include code of your attempt. – Srik Aug 09 '13 at 17:19

2 Answers2

2

Something like this does it pretty well.

I used a fake button to keep the "look and feel" consistent with the other button , I simply added the link invisible on top of it ;-)

function alertLink() {
  var doc = SpreadsheetApp.getActiveSpreadsheet();
  var app = UiApp.createApplication().setTitle('Message').setHeight('100').setWidth('400');
  var panel = app.createVerticalPanel().add(app.createHTML('Did you see my beautiful <b>Tutorial</b> ?'));
  var grid = app.createGrid(1,2).setWidth('400');
  var closeHandler = app.createServerHandler('close');
  var b1 = app.createButton("NO and I'd like to").setTitle('go to the tutorial in a new tab');
  var b2 = app.createButton("YES and I don't want to see it again",closeHandler).setTitle('close this window');
  var link = app.createAnchor('XXXXXXXXXX','http://www.google.com').setStyleAttributes({'zIndex':'1' , 'position':'fixed' , 'top':'25' , 'left':'20', 'color':'transparent' }).setTitle('go to the tutorial in a new tab');
  var G1 = app.createVerticalPanel().add(b1).add(link);
  grid.setWidget(0,0,G1).setWidget(0,1,b2);
  app.add(panel).add(grid)
  doc.show(app)
}

function close(){
  return UiApp.getActiveApplication().close();
}

Just use an onOpen trigger if you want it to execute automatically on spreadsheet open. (or rename the main function as onOpen() )

Here is how it looks like :

enter image description here

Serge insas
  • 45,904
  • 7
  • 105
  • 131
  • UiApp is deprecated. Reference: https://developers.google.com/apps-script/reference/ui/ui-app – Rubén Nov 03 '17 at 15:05
  • Yes, because, IMHO, the use of a deprecated service makes this answer not helpful nowadays. – Rubén Nov 03 '17 at 20:11
  • 4
    downvoting is for bad answers, this one is just 4 years old... personally I think this is not helpfull in any way. That said, it won't change my life but I guess you can find dozens of "deprecated" answers... there was a life before you came here :) sorry you were'nt part of it. – Serge insas Nov 03 '17 at 20:21
0

For an onOpen trigger, it's certainly a better UX to prompt the user with a dialog box offering the option to open a URL, as opposed to opening the URl automatically. See serge's answer here for how to do that (which is more up-to-date than the deprecated code in his answer on this thread).

But for other triggers (such as a menu item click) check out my answer here to open a URL automatically.

Stephen M. Harris
  • 7,163
  • 3
  • 38
  • 44