Apps script projects - q's

Hi All,

Just have a query regarding apps script.

A previous super admin had setup numerous app script projects for enterprise apps and had connected them to GCP projects.

Just have 3 questions if you're able to assist:

1. Would suspending his admin account break the connection to the apps script projects and in turn affect the enterprise app?

2. Is it possible to transfer app script projects to another super admin?

3. What is the recommendation for app script projects if they are required to be created and linked to GCP Projects? Dedicated admin account / service account?

Any info or guidance would be appreciated.

0 6 167
6 REPLIES 6

@ChasL I believe you will find that the Apps Scripts are indeed tied to the user who is running them and authorized any permissions/scopes/etc. for the scripts to do their work.  

So to answer your questions: 

So yes, suspending his account will break those scripts from running.

To transfer them, I believe you would just run the scripts as a different user and authorize all the permissions/scopes needed.

For a recommednation I would start with storing the scripts in a good shared drive, with good documentation about their installation and reason to exist.

After that, it's an interesting idea to run them from a dedicated account. Most smaller firms wouldn't waste the license fee so the documentation / storage recommendation above is likely key.

Regards,

KAM


@KAM wrote:

For a recommednation I would start with storing the scripts in a good shared drive, with good documentation about their installation and reason to exist.


Store them in a shared drive how? As a Doc? Or is there a different format you'd use?

 

@b_gorsky1 Good question.  Most of the apps scripts I write are in Google Sheets so I just store the sheets in a drive.  I like using sheets because I actually tag a cell for the output and cells for input and have a mini terminal in a way. -KAM

@KAM I'm curious, what exactly do you mean? Do you actually write the script line by line, one line in each row?

Also, what do you mean by "I actually tag a cell for the output and cells for input and have a mini terminal in a way?"

@b_gorsky1 I write the script in Sheets with the Extensions->Apps Script IDE.

I do a couple of things:

In the sheet, I tag a cell as my "terminal".

In the sheet, I tag any input variables that I need

In the Apps Script, I create a new menu entry.

 

so a snippet of code might be this to have output on B22 and input for an Email at C16

 

function getConfig(config) {
  var sheet   = SpreadsheetApp.getActiveSheet();

  config.sheet = sheet;
  config.debugEmail = sheet.getRange("C16").getValue();
  config.statusCell = "B22";
}
 
Then a function to append to the status "Terminal" cell:
 
function appendStatus(config, line) {
  var previous = config.sheet.getRange(config.statusCell).getValue();
  config.sheet.getRange(config.statusCell).setValue(previous + "\n" + line);
}
 
This would add a menu item:
function onOpen() {  
  var menu = [    
    {name: "Run Test", functionName: "runTest"},
  ];  
  SpreadsheetApp.getActiveSpreadsheet()
    .addMenu("Test", menu);
}
 Finally here's a quick runTest function that loads the config and shows status information in the "terminal" status cell on the sheet.

function runTest() {
// read config from spreadsheet tables
var config = {};

getConfig(config);
config.sheet.getRange(config.statusCell).setValue("");
appendStatus(config, "Config Loaded");
if (config.debugEmail == '') {
} else {
appendStatus(config, "Debug Email Address is set to " + config.debugEmail + " - Performing test submit instead");
}
appendStatus(config, "");

appendStatus(config, "Done\n");
}

 

This basic framework has served me incredibly well for eons and is based on other Apps scripts from 10-12 years ago as well as we looked to implement the tech.  Regards, KAM

I think I understand now. Thanks for the details!