'Linking standalone google script to sheets

Is there a specific way how you link standalone google script to sheets ? I've created a web app running from standalone script that links to more than 10 sheets, im trying to reduce the google scopes from showing view all your files to view & manage files in which the script is installed

I've added the standalone script as library to each of the file used but the moment i add

/**

  • @OnlyCurrentDoc */

to the file the scripts stops working showing error that the user can't call api

Error showed

All users have edit access to the file and they can open it when then try to do it directly by the URL of the file. I even gave edit access to the main script but it didnt make difference. The script works when i open it but anyone else it throws that error the file is stored on team drive and even users added to the drive are being showed this error

Is there any workaround other than add-on (my company opted out from cloud platform so i can't set Google Cloud Platform (GCP) project required for add-on)

This example of the code that throws the error line 18 is at var DB = SpreadsheetApp.openById(Log_errors)

    /**
*  Report app usage to logs
*/
function LOG(type, user, argsObject){
// Logs
var Log_analytics = PropertiesService.getScriptProperties().getProperty('Log_analytics');
var Log_errors = PropertiesService.getScriptProperties().getProperty('Log_errors');
var Log_tasks = PropertiesService.getScriptProperties().getProperty('Log_tasks');

switch(type){
    case "pageview":
    var DB = SpreadsheetApp.openById(Log_analytics)
    var LOG = DB.getSheetByName('Views')
    LOG.appendRow([new Date(),user,argsObject[0],argsObject[1],argsObject[2],argsObject[3],argsObject[4],argsObject[5]])
    break;   

    case "exception":
    var DB = SpreadsheetApp.openById(Log_errors)
    var LOG = DB.getSheetByName('Log')
    LOG.appendRow([new Date(),user,argsObject[0],argsObject[1],argsObject[2],argsObject[3],argsObject[4],argsObject[5]])
    break;   

    case "event":
    var DB = SpreadsheetApp.openById(Log_analytics)
    var LOG = DB.getSheetByName('Events')
    LOG.appendRow([new Date(),user,argsObject[0],argsObject[1],argsObject[2],argsObject[3],argsObject[4]])
    break;  

    case "task":
    var DB = SpreadsheetApp.openById(Log_tasks)
    var LOG = DB.getSheetByName('Tasks')
    LOG.appendRow([new Date(),user,argsObject[0],argsObject[1],argsObject[2],argsObject[3],argsObject[4],argsObject[5]])
    break;   
    default: return null  
  }
}

/**
*  Record report generation
*/
function NEW_report(ID,type,link,color,title,msg,location,avatar){
var DB = SpreadsheetApp.openById(PropertiesService.getScriptProperties().getProperty('DB_BACKEND'))
var TAB = DB.getSheetByName('DB_reports')

var email = Session.getActiveUser().getEmail()
var user = username(email)
var timestamp = new Date()

TAB.appendRow([type,color,title,msg,avatar,user,timestamp,link,ID,location])
}

This how manifest is showed

enter image description here

Scopes looks correctly as it shows vie & manage sheets where script is installed



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source