0
votes

I have a library containing a webApp (using UiApp with doGet) intended to work with a specific spreadsheet from each user of that library.

How a user of that library could pass the Id of his own spreadsheet to the library?

Thanks

Notes about the current code, on the library (myLib)

var mainDoc = SpreadsheetApp.openById("abc123"); // should be user's spreadsheet Id 
function mainUiApp() {   
  // something here using handler1 below 
  return app; 
}
function handler1() {
  // using mainDoc spreadsheet 
}

Notes about the current code, on the user of myLib

var mainDocClient = SpreadsheetApp.openById("xyz789");
function doGet() {
  return myLib.mainUiApp();
}
1

1 Answers

0
votes

You can pass a spreadsheet ID as a parameter of the mainUiApp function. Here is an example

The myLib code is

var mainDoc = null;

function mainUiApp(ssID) {   
  mainDoc = SpreadsheetApp.openById(ssID);
  // ...
  return app; 
}

User code is

function doGet() {
  return myLib.mainUiApp("xyz789");
}