EgzonArifi
EgzonArifi

Reputation: 830

UiApp has been deprecated. Please use HtmlService instead

I have a google script that I'm using in google spreadsheet to export some data from there. Recently they update the spreadsheet and I'm getting this error:

UiApp has been deprecated. Please use HtmlService instead

var app = UiApp.createApplication().setTitle('Export');

Does anyone had this problem, any solution?

Thank you

Upvotes: 14

Views: 21738

Answers (1)

Wicket
Wicket

Reputation: 38190

Please start by learning the pretty basics of developing a web application using "vanilla" HTML/JavaScript/CSS. Mozilla Developers Network and freecodecamp.com among many others might be helpful.

Once you know the pretty basics of developing a web application, read HTML Service: Create and Serve HTML. Below is a very simple code for a web app including HTML/JavaScript/CSS.

function doGet(e){
  const css = '<style> p { color: blue;} </style>';
  const html = '<p>Hello world!</p>';
  const js = '<script>document.addEventListener("click",() => alert("Clicked!"))</script>';
  return HtmlService.createHtmlOutput(css + html + js)
  .setTitle('My first web app')
  .addMetaTag('viewport', 'width=device-width, initial-scale=1');
}

Below is the above code adapted to be used to show a simple modal dialog in Google Sheets

function showDialog(e){
  const css = '<style> p { color: blue;} </style>';
  const html = '<p>Hello world!</p>';
  const js = '<script>document.addEventListener("click",() => alert("Clicked!"))</script>';
  SpreadsheetApp.getUi().showModalDialog(
    HtmlService.createHtmlOutput(css + html + js), 
    'My first modal dialog'
  )
  .setWidth(300)
  .setHeight(100)
}

If you don't have time or will to learn, consider to use a no-code tool. As you are already using Google Sheets, Google AppSheet might be a good place to start specially if your spreadsheet already has data tables (sheet having column headers on the first row, values below each of them). To create a no-code app from Google Sheets, click on Extensions - AppSheet.

Resources

Related

Upvotes: 1

Related Questions