0

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");
    }
}
1
  • 2
    Use .setValue() not .setvalue(), case is important. Commented Nov 21, 2019 at 8:58

1 Answer 1

1

Use .setValue() instead of .setvalue().

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.