Hello Everyone,
I hope this message finds you well. I am currently writing a JavaScript code to link all records from one table to another. For this purpose, I am using a loop, but each time the code runs, I receive the following error message:
Failed to execute operation on server: Operation invalid.
Here is the code I have written (I have debugged it using AI Copilot):
async function updateLinks() {
const rows = await base.getRows('list time', 'Default View');
const rowss = await base.getRows('list task', 'Default View');
// vars
const viewName = 'Default View';
const columnR2 = 'Formula';
// code - don't change careless!
const currentRow = base.context.currentRow;
const table = base.getActiveTable();
const view = base.getViewByName(table, viewName);
// Get the initial value of column r2
let x = rows.map(row => row[columnR2]);
const updatedRows = [];
let pos = 0;
rows.forEach((row) => {
updatedRows.push(rows[pos]._id);
pos++;
});
await base.updateLinks('1M54', 'list task', 'list time', x, updatedRows); // Changed from [updatedRows] to updatedRows
}
updateLinks();
I would greatly appreciate any guidance or assistance in resolving this issue.
Thank you in advance for your help.
Best regards