Need help authorizing Google Sheets scripts for domain users -


i have created 3 scripts (but think part of same app?) deployed sheets add-on company (all users @ our domain). administrator on our account , approved app domain users.

first, users click button prompts them name copy of current google sheet (a payment request form) , saves in correct folder on our drive. open new file , after filling in, button on sheet opens script transfers ownership of file employee in charge of approving request, , makes else viewers only. employee approves request, presses button runs script allow accountant edit document.

the scripts work, second 2 scripts ask authorization every time run (even me). saw earlier similar question on authorizing google apps script think 1st answer applies when running script web app. i'm willing that, barely understand process (my first time writing script). thanks.

1.

function saveasspreadsheet() {    var sheet = spreadsheetapp.getactive();   var folder = driveapp.getfolderbyid('xxxxxxxx');   var ui = spreadsheetapp.getui();   browser.msgbox("please rename document. wait prompts.");   var filename = browser.inputbox("rename file this: yyyy.mm.dd payee name");   driveapp.getfilebyid(sheet.getid()).makecopy(filename, folder); } 

2.

function setowner() {    var sheet = spreadsheetapp.getactive();   var file = driveapp.getfilebyid(sheet.getid())   var owner = file.getowner().getemail();   file.setowner("joe@ourdomain.com"); } 

3.

function setsharing () {    var sheet = spreadsheetapp.getactive();   var file = driveapp.getfilebyid(sheet.getid())   var owner = file.getowner().getemail();   var user = file.geteditors();   if (user = "jill@ourdomain.com"){   file.addeditor("jill@ourdomain.com")   } else if (user = "sue@ourdomain.com"){   file.setsharing(driveapp.access.domain, driveapp.permission.view);   } else {   file.setsharing(driveapp.access.domain, driveapp.permission.view); }} 


Comments

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -