I have this script that picks the last updated row from google sheet and successfully posts it to the project's system via external API.
Now I added a few lines of code so that it updates fetch success or failure on a last cell of the row it picked data from, but I keep getting Cannot find function set value in object Range. I am pretty new to javascript so, I will appreciate any assistance.
Here is the code without the auth key.
function lastRowData(){
var ss = SpreadsheetApp.getActive()
var sheet = ss.getActiveSheet()
var lastRow = sheet.getLastRow()
var lastCol = sheet.getLastColumn()
var lastRowData = sheet.getRange(lastRow,1,1,lastCol).getValues()
return lastRowData[0]
}
function myFunction() {
var lastRow = lastRowData()
var data = {
'name':lastRow[2],
'client': lastRow[3],
'starts_at':lastRow[5],
'ends_at':lastRow[6],
'project_state':lastRow[4],
};
var payload = JSON.stringify(data);
var options = {
'method': 'POST',
'Content-Type': 'application/json',
'payload': payload,
'muteHttpExceptions': true
};
var url = 'https://api.10000ft.com/api/v1/projects?auth=**token**';
enter code here var response = UrlFetchApp.fetch(url, options);
var ss = SpreadsheetApp.getActive();
var sheet = ss.getActiveSheet();
if (response.getResponseCode() === 200) {
sheet.getRange("X1").setvalue("Yes");
}
else {
sheet.getRange("X1").setvalue("No");
}
}
.setValue()not.setvalue(), case is important.