-1

I understand that we can write and read tasks using Google Apps Script. I was wondering if I could have the side bar open, as I click on a certain cell, containing a data. Then, the side bar would appear, showing the tasks due on that date.

This is what I'm talking about: enter image description here

JM Gelilio
  • 3,482
  • 1
  • 11
  • 23
onit
  • 2,275
  • 11
  • 25
  • I my laptop world the task window covers up the sidebar – Cooper Nov 24 '21 at 22:36
  • Here's a dummy sidebar try it: `function launchASideBar() { SpreadsheetApp.getUi().showSidebar(HtmlService.createHtmlOutput('

    Hello World

    ').setTitle('Blank Sidebar')); }`
    – Cooper Nov 24 '21 at 23:16
  • About your question of `I was wondering if I could have the side bar open, as I click on a certain cell, containing a data.`, I thought that this thread might be the answer for your question. https://stackoverflow.com/q/62647068 – Tanaike Nov 25 '21 at 00:50

1 Answers1

0

Unfortunately there is no way to open the Task sidebar from the UI class. As @Tanaike references, there is also no way to activate the UI from a Simple Trigger.

They cannot access services that require authorization.

onSelectionChange(e) Simple Trigger pointing to "https://www.googleapis.com/auth/script.container.ui" scope in this case

You could make a Feature Request, asking for that functionality to be integrated in Apps Script.

As a workaround you can activate a sidebar by creating an Installable Trigger, and using Task API to filling it, but in that case you would only have the edit and change events available. The trigger would only change when a value or the spreadsheet structure changed.

Code.gs
const test = (e) => {
  // Getting all the task from a certain TaskList
  // this should be tweaked for obtain the TaskList from a
  // certain day 
  var tasks = Tasks.Tasks.list(TASKLIST_ID)
  if (!tasks.items) return
  Logger.log(tasks)
  let htmlContent = tasks
    .items
    .map(task => `<li>${task.title}-${task.note}</li>`).join(' ')
  SpreadsheetApp.getUi()
    .showSidebar(HtmlService
      .createHtmlOutput(htmlContent)
      .setTitle('Custom Notes'))
}
Documentation
Emel
  • 2,283
  • 1
  • 7
  • 18
  • 1
    You can open a sidebar from a menu. Then sidebar =[poll](https://stackoverflow.com/questions/30628894/how-do-i-make-a-sidebar-display-values-from-cells/30634581#30634581)> server(properties)<=`onSelectionChange()` – TheMaster Nov 25 '21 at 20:49