0

Trying to run

function textVersion() {
  var app = UiApp.createApplication().setTitle('Time Picker');
  var main = app.createGrid(2, 4);
  var date = app.createDateBox().setName('date');
  var hour = app.createTextBox().setName('time').setWidth('150');
  var button = app.createButton('validate')
  main.setWidget(0,0,app.createLabel('Choose Date')).setWidget(0,1,app.createLabel('Enter Hours:minutes'))
  main.setWidget(1,0,date).setWidget(1,1,hour);
  main.setWidget(1,3,button)
  var handler = app.createServerHandler('show2').addCallbackElement(main)
  button.addClickHandler(handler)
  app.add(main)
  ss=SpreadsheetApp.getActive()


  ss.show(app) // here is problem , how to fix that ?

}

but have this error you do not have permission to call SHOW

Rubén
  • 34,714
  • 9
  • 70
  • 166
Grigori Jlavyan
  • 1,871
  • 3
  • 19
  • 39
  • 1
    UiApp is a deprecated class. Reference https://developers.google.com/apps-script/reference/ui/ui-app – Rubén Jun 03 '17 at 01:55
  • Does this answer your question? [No permission to call msgBox in Google Apps Scripting](https://stackoverflow.com/questions/10506105/no-permission-to-call-msgbox-in-google-apps-scripting) – Rubén Jun 28 '20 at 00:07
  • Besides that UiApp is deprecated, apparently the only answer assumption regarding that this questions is about a custom function is correct. – Rubén Jun 28 '20 at 00:09

1 Answers1

1

This is true. If I am correct, you made a function and are trying to use it in your spreadsheet in a cell like "=textVersion()". Is that correct? It happens in circumstances where you are trying to run a custom function from a cell, and that function has illegal elements like "ss.show()".

Please correct me because I am assuming some things here. But if my assumptions are correct so far, what you need here is a button instead, so you can (in the top menu of the spreadsheet) Insert > Image. Then right click on the image and Assign the script "textVersion" to it. Then the UI should work now since it is being called by a person rather than your spreadsheet.

Augustine C
  • 794
  • 6
  • 20
  • 1
    By one hand UiApp is a deprecated class. Reference https://developers.google.com/apps-script/reference/ui/ui-app by the other, when it was an active class it can't be used on a custom function, so doesn't make sence to call the function in a formula. – Rubén Jun 03 '17 at 01:58
  • @Rubén Thank you for the input. I used and tested the OP's code in the Script Editor before responding, in a variety of different cases, and was only able to get the exact error in question when calling this from a formula, which, as you point out, makes sense. At this point in time, this seems unrelated to deprecation because it runs fine outside a formula. Please correct me if I am missing something so I can learn. – Augustine C Jun 03 '17 at 05:01
  • 2
    IMO you are probably perfectly right. It's a very common mistake found in many posts. – Serge insas Jun 03 '17 at 05:47