Vinay Joseph
Vinay Joseph

Reputation: 5655

Generic Error on SpreadsheetApp.openById(id) v2 Spreadsheet

I have an app-script which reads shows from a sheet in a spreadsheet. Below is a snippet from my code relevant to the issue I am experiencing.

var mode = "prd";
var TimeSheetMain = "924270483";

/**
 * Get Sheet by ID
 */
function getSheetByID(ID){
 var s = SpreadsheetApp.getActiveSheet();
/*Line 17*/
 var ss = SpreadsheetApp.openById(TimeSheetMain);
 return ss;
}

I am getting a generic error on Line 17

[14-04-04 14:16:38:739 EST] Execution failed: Bad value (line 17, file "Code") [0.241 seconds total runtime]

Any ideas ?

Upvotes: 2

Views: 3444

Answers (2)

Rawan
Rawan

Reputation: 31

You are mistakenly using the Spreadsheet's name.

The ID should be the Spreadsheet ID which you can retrieve from the Spreadsheet's URL.

For example in the below Spreadsheet URL, the ID is what you see below in bold https://docs.google.com/a/lan.com/spreadsheets/d/1Lxevgi4fRXWp_MujPfyQgo15_WeHVj6j4KVoHKju5Ws/edit#gid=0

If your document had the URL sample above, the openById function look like the below: var ss = SpreadsheetApp.openById("1Lxevgi4fRXWp_MujPfyQgo15_WeHVj6j4KVoHKju5Ws");

You can find more information about the openById function on the Google Developer's website if needed.

https://developers.google.com

Upvotes: 3

Zig Mandel
Zig Mandel

Reputation: 19864

Dont know where you got that id but its definitely not a valid spreadsheet id. Also unclear what you mean by v2 as there is no such thing.

Upvotes: 0

Related Questions