Hello Community,
I've made a script in an automation and some part of it doesn't execute and I can't figure out why.
In the script below, the "if" test is pulled so I can't find "11-OK" in log but directly "13-END" (I've put an always true condition only for testing purpose). Could somebody tell me why ?
Thanks in advance
let clientTarget = "";
let salonTarget = "";
let totalCommandes = 0;
let inputConfig = input.config();
let subtotal = inputConfig["subtotal"];
console.log("1-subtotal: " + subtotal);
let total = inputConfig["total"];
console.log("2-total: " + total);
let client = String(inputConfig["client"]);
console.log("3-client: " + client);
let salon = String(inputConfig["salon"]);
console.log("4-salon: " + salon);
let table = base.getTable('Client-Salon');
let query = await table.selectRecordsAsync({fields: ['Client', 'Salon', 'Total Commandes']});
console.log("5-query:" + query);
for (let record of query.records) {
console.log("6-record: " + record);
let ojbClientTarget = record.getCellValue('Client');
console.log("7-ojbClientTarget:" + ojbClientTarget);
if (ojbClientTarget !== null) {
clientTarget = String(ojbClientTarget[0]['name']);
console.log("8-clientTarget: " + clientTarget);
}
let objSalonTarget = record.getCellValue('Salon');
if (objSalonTarget !== null) {
salonTarget = String(objSalonTarget[0]['name']);
console.log("9-salonTarget: " + salonTarget);
}
totalCommandes = record.getCellValue('Total Commandes');
console.log("10-Total Commandes: " + totalCommandes);
console.log(typeof(client));
console.log(typeof(clientTarget));
if (true && client == clientTarget) {
console.log['11-OK'];
} else {
console.log('12-KO');
}
console.log('13-END');
}