To be clear, I looked at other posts in Stackoverflow on this issue before posting the problem. So far nothing has helped so i am reaching out to the community to help. The error is:
Error Exception: The parameters () don't match the method signature for SpreadsheetApp.Spreadsheet.getRange.
Here is what i have in a function called code.gs
var spreadsheet = SpreadsheetApp.getActiveSpreadsheet();
var ss = spreadsheet.getSheetByName("Main");
var configSheet = spreadsheet.getSheetByName("Config");
function createid()
{
var colnum = getColIndexByNameandRow("UID",ss,1)
};
UID is an actual row header in my spreadsheet, and I want to return the column number from the sheet. I developed a function that returns the column Index. The function is listed below
function getColIndexByNameandRow(colName,mysheet,rs)
{
/*
ColName is the name of the column your looking for, string value
mysheet is the recordset for the sheet you are searching for the column
(R)ow (S)tart (rs) is the row position where you want the column search to start
*/
if (rs==undefined) rs=1;
var numColumns = mysheet.getLastColumn();
var row = mysheet.getRange(rs, 1, 1, numColumns).getValues();
for (i in row[0]) {
var name = row[0][i];
if (name == colName)
{
return parseInt(i) + 1;
}
}
return -1;
};
I know my ss active sheet declaration is working because the line before it var numColumns = mysheet.getLastColumn(); works fine and returns the number of rows. The following line chokes every time it runs:
var row = mysheet.getRange(rs, 1, 1, numColumns).getValues();
Whats interesting is I am using the same function with another project, and its flawless n no issues.
I have tried changing .getValues() to .getDisplayValues() with no success.
Anyone got anything else I can try.
Thanks in advance!