I have a spreadsheet linked to a standalone script that imports task from my tasklist. It works fine when I am the user but does not work in share user account.
The codes in the standalone script is
function getTasks() {
var tasklistID="mytasklistid";
var tasks=Tasks.Tasks.list(tasklistID);
return tasks
}
Code in Bound script is
function getTask(){
var tasks = TaskManagerScript.getTasks()
Browser.msgBox(tasks)
}
When I run the code in my account I get the tasks from tasklist with the specified id as expected. But when I run it from a different user account I get the the tasklist of the other user.
How do I make the code return the tasks from the list with the specified id when other users run it.
If my understanding is correct, how about this answer?
OnEdit event trigger is run as owner of Spreadsheet. So when users edit the Spreadsheet, the script is run with your task list ID. But from your question, it's when I run it from a different user account I get the the tasklist of the other user.
. I could confirm that in my environment, when users edit to the shared Spreadsheet, the script is run as owner (me), and my task list ID could be used. Unfortunately, I couldn't replicate your situation. So, in order to confirm this situation, can you test the following flow?
TaskManagerScript
.Put the script to the script editor. The script is as follows.
function getTask(e) {
var tasks = TaskManagerScript.getTasks();
e.source.appendRow([JSON.stringify(tasks)]);
}
Install OnEdit trigger to getTasks()
.
getTasks()
by the script editor and authorize the scopes.
By above flow, when the user edits the sheet, the result retrieved with your task list ID is returned.