Reputation: 85
I am trying to modify data in a spreadsheet based on the data entered in another spreadsheet. To access the data within the sheet i can use the SpreadsheetApp.getActiveSpreadsheet(); function but how to reference another spreadsheet from there?
Upvotes: 2
Views: 4254
Reputation: 1217
You could also build a doPost()
function in the sheet #2, deploy as API.
This allows you to trigger actions in that sheet by HTTP request.
Depending on the size of the code, this can be easier to manage since every sheet is only manipulating itself.
Upvotes: 0
Reputation: 815
To reference another spreadsheet you need to find its Id
Look at the URL
https://docs.google.com/spreadsheets/d/THIS IS THE ID/edit#gid=0
copy the Id from the URL
In the sheet that you want to read this from create a reference by using this
var othersheet = SpreadsheetApp.openById("PUT THE ID IN HERE");
Now when you use othersheet you can access anything onit., assuming you have permission
Upvotes: 4