Closed rafaelalemar closed 8 years ago
Rafael - The "m" ID is the project key. You need to use the Drive File ID for the script, which begins with a "1", and can be obtained from the URL when you open the script editor from your bound script.
On Tue, Jul 5, 2016 at 1:48 PM, Rafael Vidal notifications@github.com wrote:
You guys have committed a version that block gapps innit when ID begins with M, but all my bounded scripts starts with M. I know I can't push code to bounded scripts, but I could pull it. I used to backup my bounded scripts this way. Any work around?
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/danthareja/node-google-apps-script/issues/38, or mute the thread https://github.com/notifications/unsubscribe/AMPN9Glmd0VccPkN86hVBn7G086M4tFdks5qSpjkgaJpZM4JFXLA .
The eval
could help for this.
function onOpen(){
magic(getSource(), 'onOpen');
}
function getSpreadsheetId(){
magic(getSource(), 'getSpreadsheetId');
}
function magic(source, fn){
eval('(' + source + ')')(fn);
}
function getSource(){
return HtmlService.createHtmlOutputFromFile('source').getContent();
}
function doGet(){
return ContentService.createTextOutput(getSource());
}
function(fn){
var ___ = {};
___.args = Array.prototype.slice.call(arguments, 1);
___.onOpen = function(){
SpreadsheetApp.getUi().createMenu('menu').addItem('get id', 'getSpreadsheetId').addToUi();
};
___.getSpreadsheetId = function(){
SpreadsheetApp.getUi().alert(SpreadsheetApp.getActive().getId());
};
return ___[fn].apply(undefined, ___.args);
}
@hess-g Thanks for the quick reply. My old bound script file ID all start with M. I just created a new spreadsheet and open the script editor to confirm the file ID starts with 1. But my old ones still start with M and the project key starts with 1. So, I pick up the project key and it worked...
@oshliaer Your script would give me the spreadsheet id, not the script ID.
You guys have committed a version that block gapps innit when ID begins with M, but all my bounded scripts starts with M. I know I can't push code to bounded scripts, but I could pull it. I used to backup my bounded scripts this way. Any work around?