Error msg from custom function when trying to open another spreadsheet. “You do not have permission to perform that action.”

南楼画角 提交于 2021-02-10 20:24:17

问题


I have a custom function that I want to use to retrieve the cell value in a sheet from another spreadsheet. The two parameters of the function are row and col and they determine the cell to reference. Whenever I try to use the function, I get the error "You do not have permission to perform that action.", pointing to the line with the openByID method. Here is my custom function:

function TEST(row,col) {
    var formDataSpreadsheet = SpreadsheetApp.openById(FORM_DATA_SPREADSHEET_ID);
    SpreadsheetApp.setActiveSpreadsheet(formDataSpreadsheet);
    var formDataSheet = formDataSpreadsheet.getSheetByName(WEBSITE_FORM_DATA_SHEET_NAME);
    formDataSpreadsheet.setActiveSheet(formDataSheet);
    return formDataSpreadsheet  
}

Do I need to publish the FORM_DATA_SPREADSHEET? Any help is greatly appreciated.


回答1:


Sorry, can't do that in a custom function:

Quote from Google documentation:

If your custom function throws the error message "You do not have permission to call X service.", the service requires user authorization and thus cannot be used in a custom function.

Google Documentation - Custom functions



来源:https://stackoverflow.com/questions/31465600/error-msg-from-custom-function-when-trying-to-open-another-spreadsheet-you-do

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!