Answer the question
In order to leave comments, you need to log in
How to call two functions in sequence?
Friends, good afternoon!
Lately my ID replacement function has started returning undefined. I don't understand why this is.
Plus, don't like this feature:
Функция в библиотеке которая меняет значения в ячейках Google таблицы
function tryChangeVID(f,r, db, table, col) {
var sheet = db.getSheetByName(table);
var range = sheet.getRange(col);
var values = range.getValues();
f = Number(f);
r = Number(r);
var res = f;
for (var i = 0; i < values.length; i++) {
if (values[i][0] === f) {
values[i][0] = r;
res = r;
}
}
range.setValues(values);
return res;
}
Мне нужно поменять ИД в двух таблицах. Коровы и их телята
exports.changeVID = function(find, repl, db){
var result = tryChangeVID(find, repl,db,"Animals", "A:A");
if(result === repl){
result = tryChangeVID(find, repl, db, "Calves", "C:C");
}
return result;
}
Answer the question
In order to leave comments, you need to log in
The condition will not be fulfilled if in the first call, in the first table, there was no replacement.
Logic - as written, it is carried out. Mikhail correctly noted in the comment : removeif(result === repl)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question