WAI
Status Update
Comments
ja...@gmail.com <ja...@gmail.com> #2
Comment has been deleted.
ja...@gmail.com <ja...@gmail.com> #3
Hi, an update of findings I did.
the issue does not seems to come from getValues() method. But instead, it comes from SpreadsheetApp.getActiveSheet()
I have 3 sheets in a spreadsheet. To first make a sheet active, is by going to spreadsheet and simply click to open the sheet.
2nd, by using the command SpreadsheetApp.getActiveSheet() should return the current opened sheet. but instead, by default somehow, it now returns only the 1st sheet.
As attachment, you can see that I have "TestScript" sheet selected and open.
after that, on the another attachment, you can see that by using SpreadsheetApp.getActiveSheet(), it returns me the 1st sheet.
the issue does not seems to come from getValues() method. But instead, it comes from SpreadsheetApp.getActiveSheet()
I have 3 sheets in a spreadsheet. To first make a sheet active, is by going to spreadsheet and simply click to open the sheet.
2nd, by using the command SpreadsheetApp.getActiveSheet() should return the current opened sheet. but instead, by default somehow, it now returns only the 1st sheet.
As attachment, you can see that I have "TestScript" sheet selected and open.
after that, on the another attachment, you can see that by using SpreadsheetApp.getActiveSheet(), it returns me the 1st sheet.
lo...@google.com <lo...@google.com> #4
Hello,
I try to reproduce the issue, but this is not reproducible on my side. This is the code that I am using:
const sS = SpreadsheetApp.getActiveSheet()
function getNames() {
const name = sS.getSheetName()
console.log(name)
}
And it is working as expected. Please provide an example where this issue is reproducible.
Have a nice day!
ja...@gmail.com <ja...@gmail.com> #5
Hello~ sorry on the issue, i just tested on my side just few seconds ago. the issue seems to be gone somehow magically. do not know how does the issue get fixed. it's the same piece of code and same sample data im using few hours ago haha. I would say we close this tracker ?
thank you. have a nice day.
thank you. have a nice day.
lo...@google.com <lo...@google.com> #6
Hello.
Thanks for the feedback
ja...@gmail.com <ja...@gmail.com> #7
Hi there, Im back with the issue again. This time I am able to give a very specific steps to reproduce the issue.
Straight to the point, App Script command (SpreadsheetApp.getActiveSheet()) will return you the default of 1st Sheet IF the spreadsheet was OPEN AFTER the app script.
Local Environment
1. Windows 10
2. Chrome browser version - Version 107.0.5304.107 (Official Build) (64-bit)
Steps
1. Please close all existing AppScript and Spreadsheet tab before running actual behavior and expected behavior (atleast i did myself with this)
2. Run the expected behavior to see the correct result first.
- Close all appscript and spreadsheet tabs if you have not do so yet.
3. Run the Actual behavior that i did currently to reproduce the bug.
4. You may you use back your code to see the sheet name or just use mine.
function test() {
Logger.log(SpreadsheetApp.getActiveSheet().getName());
}
Expected behavior (Wont have any issues)
1. Open up Spreadsheet.
2. Click on the desired sheet to make it active (Example: Sheet 2)
2. Go to "Extensions" tab
3. Go to "App Script"
4. Run the method, and you will get "Sheet 2".
Actual behavior (Will cause the issue)
1. Go to App Script (https://script.google.com/home )
2. Go to My Project
3. Selected and open the app script project that you have created.
4. On the App Script screen, navigate to "Overview" screen on the left sidebar menu.
5. Click on the container link that will brings you to open the spreadsheet.
6. On the opened up spreadsheet, click on the desired sheet to make it active (Example: Sheet 2)
7. Go back to App script tab, Run the method, and you will get "Sheet 1".
Straight to the point, App Script command (SpreadsheetApp.getActiveSheet()) will return you the default of 1st Sheet IF the spreadsheet was OPEN AFTER the app script.
Local Environment
1. Windows 10
2. Chrome browser version - Version 107.0.5304.107 (Official Build) (64-bit)
Steps
1. Please close all existing AppScript and Spreadsheet tab before running actual behavior and expected behavior (atleast i did myself with this)
2. Run the expected behavior to see the correct result first.
- Close all appscript and spreadsheet tabs if you have not do so yet.
3. Run the Actual behavior that i did currently to reproduce the bug.
4. You may you use back your code to see the sheet name or just use mine.
function test() {
Logger.log(SpreadsheetApp.getActiveSheet().getName());
}
Expected behavior (Wont have any issues)
1. Open up Spreadsheet.
2. Click on the desired sheet to make it active (Example: Sheet 2)
2. Go to "Extensions" tab
3. Go to "App Script"
4. Run the method, and you will get "Sheet 2".
Actual behavior (Will cause the issue)
1. Go to App Script (
2. Go to My Project
3. Selected and open the app script project that you have created.
4. On the App Script screen, navigate to "Overview" screen on the left sidebar menu.
5. Click on the container link that will brings you to open the spreadsheet.
6. On the opened up spreadsheet, click on the desired sheet to make it active (Example: Sheet 2)
7. Go back to App script tab, Run the method, and you will get "Sheet 1".
Description
1. Create a google sheet, fill in data any data from range of A1 to C3
2. go to Extensions > App Scripts
3. paste the sample code provided and run
function testGoogleScript(){
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getSheets()[0];
var range = sheet.getRange(1, 1, 3, 3);
var values = range.getValues();
// Print values from a 3x3 box.
for (var row in values) {
for (var col in values[row]) {
Logger.log(values[row][col]);
}
}
}
What is the expected output? What do you see instead? If you see error messages, please provide them.
you should see the data that you have entered earlier in the spreadsheet. But instead, the console returns empty values.
Please provide any additional information below.