Hi All,
I am struggling with my scripting code and it looks ok but it doesn’t run. I cant work out what is wrong.
I am trying to get it to compare the name in one table with the name in a second table. It it finds the name in the second table then it does nothing but if it cannot find the name in the second table then it adds in the name from the first table.
Any help would be appreciated.
var date = new Date();
let today = base.utils.formatDate(date);
output.text(today);
const copyTableName = 'Companies';
const copyViewName = 'Default View';
const copyColumnName = 'Name';
const pasteTable = 'Jobs';
const pasteViewName = 'Default View';
const pasteColumnName = 'Name';
const table = base.getTableByName(copyTableName);
const view = base.getViewByName(table, copyViewName);
const rows = base.getRows(table, view);
const outputTable = base.getTableByName(pasteTable);
const outputView = base.getViewByName(outputTable, pasteViewName);
const outputRows = base.getRows(outputTable, outputView);
for (let i = 0; i < rows.length; i++) {
for (let a = 0; a < outputRows.lenght; a++) {
selectedRow = rows[i];
selectedRow1 = outputRows[a];
let nameInRow = selectedRow[copyColumnName];
let nameInRow1 = selectedRow1[pasteColumnName];
if (nameInRow != nameInRow1) {
output.text("worked");
const selectedName = selectedRow[copyColumnName];
base.addRow(outputTable, {[pasteColumnName]: selectedName});
}
}
};
output.text(today);
output.text("end");