I've been trying to compare balance and totalPrice variables, so that trades which are over balance of the account, aren't recorded, but I'm seeing errors, with no messages, it's just stuck on else statement, when I deleted else statement, results are null, not even 'Failed' is printed.
function GenieBook() {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var trade = ss.getSheetByName("Genie");
var tradeBook = ss.getSheetByName("Trade Data");
var tradeDataImport = ["B13", "E13", "G13", "I13"];
var tradeDataExport = tradeDataImport.map(f => trade.getRange(f).getValue());
var balance = SpreadsheetApp.getActiveSheet().getRange("B10");
var totalPrice = SpreadsheetApp.getActiveSheet().getRange("I13");
if( balance > totalPrice ){
SpreadsheetApp.getActiveSheet().getRange("L13").setValue("Success!");
tradeBook.appendRow(tradeDataExport);
}
else{
SpreadsheetApp.getActiveSheet().getRange("L13").setValue("Failed!");
}
//console.log(tradeDataExport)
}
CodePudding user response:
You have omitted getValue()
var balance = SpreadsheetApp.getActiveSheet().getRange("B10").getValue();
var totalPrice = SpreadsheetApp.getActiveSheet().getRange("I13").getValue();