Cannot call DocumentApp.getUi() from a time based trigger

375 views
Skip to first unread message

Sneha Krishna Kumaran

unread,
Jul 9, 2021, 6:16:54 PM7/9/21
to Google Apps Script Community
I'm trying to set up an alert that appears every 5 minutes on a google document. I've gotten the alert to show up by itself, but I'm running into the errors "Cannot call DocumentApp.getUi() from this context" whenever I run myFunction inside my time based trigger. Is there another way I can get an alert to pop up without using .getUI()? 

function createTimeDrivenTriggers() {
    // Trigger every at 5 min on document
    ScriptApp.newTrigger('myFunction')
    .timeBased()
    .after(1000*60)
    .create();
}

function myFunction() {
DocumentApp.getUi().alert("Please remember to update your progress towards your feedback goal.")
}

Clark Lind

unread,
Jul 10, 2021, 7:42:11 AM7/10/21
to Google Apps Script Community
You might try using a custom modal with html. Within the html file, you could use javascript. You might be able to set a JS timer to show/hide the modal. I'm not positive this is possible, but something you can experiment with.
Reply all
Reply to author
Forward
0 new messages