2-way Sync: Non-row ID

preview_player
Показать описание
Setting up 2-way sync within the same spreadsheet where the ID and the row DO NOT have a mathematical relation.
Important notes:
* Remember to increment the /row/ variable after the loop
* This assumes the FILTER()/QUERY()/IMPORTRANGE() etc. formula is already setup and functioning properly.

Sheet (to copy from the File menu)

Script:
function onEdit(e){
if (!e) throw "Do not run manually";

syncNonRow(e);
}

function syncNonRow(e){
let row = 0;
if (ids[row][0] === id)
break;
}
row++;
}

Connect with me:
• Twitter @FarrisSpencer

Рекомендации по теме
Комментарии
Автор

Thank you. I'll be waiting for the next one. Great script tutorial. It will improve my shared google sheets at my workplace (Portuguese school)

rmtgbesds
Автор

This is amazing. Trying to adapt it to run with multiple spreadsheets (to prevent Mary or John from seeing each others work, or the database) but running into problems. Any advice?

khkgkhkg
Автор

Hey Spencer, awesome tips here! Does this work between 2 different google sheets, instead of 2 tabs in the same sheet? And if so, does all users need read/edit permission to the master google sheet in order for the script to sync data from a child google sheet to a master google sheet?

yannhuet
Автор

Hi Spencer, what should we modify in the script if the unique id columns is at C?

seabreezebeach
Автор

How do I do when the filter formula is not in A2 but in A10 for example? and if I change the column of the filter formula?

How do I do this without the header disappearing?

eliasnogueira
Автор

If you could get this to work with Checkboxes -that would be useful. Saves typing TRUe and FALSE or using data validation [TRUE, FALSE] dropdown on the MARY tab Database allows Checkboxes but the filtered views don't activate (only show the Database state TRUE or FALSE). But thank you this is truly a game changer in data collection within Sheets.

nssdesigns
Автор

function onEdit(e) {
if (!e)
throw "Do not run onEdit from script editor";
const src = e.source.getActiveSheet();
const r = e.range;
moveProcessed(src, r);
syncNonRow(src, r);
}

function moveProcessed(src, r) {
if (src.getName() != "NEW VEHICLES IN" || r.columnStart != 11) return;
const dest = PRODUCTION");
r.offset(0, -10, 1, + 1, 1, 1, 10));
src.deleteRow(r.rowStart);
}

function syncNonRow(src, r){
if (src.getName() == "ACTIVE PRODUCTION" || r.rowStart == 3 || r.columnStart == 2) return;
r.clear();
let id = src.getRange(r.rowStart, 1).getValue();
const db = PRODUCTION");
const ids =
let row = 0;
for (row; row < ids.length; row++){
if (ids[row][0] === id)
break;
}
row++;
db.getRange(row, r.columnStart).setValue(e.value);
}

function syncWithRow(e){
if (src.getName() == "ACTIVE PRODUCTION" || r.rowStart == 3 || r.columnStart == 2) return;
r.clear();
let id = src.getRange(r.rowStart, 2).getValue();
let row = id + 1;
let db = PRODUCTION");
db.getRange(row, r.columnStart).setValue(e.value);
}



Im using the combine 2 scripts code, works except that the value to sync returns the original one... is not overwriting
it... any idea?

mauryhernandez