user3932313
user3932313

Reputation: 85

modifying another spreadsheet from within a spreadsheet : Google Apps Script

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

Answers (2)

Slawa
Slawa

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

Niccolo
Niccolo

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

Related Questions