'Google Apps Script - Two ways sync dynamically updating

I have a huge sheet containing enumerated rows, each one containing data of a single film. I need to have another sheet listing the rows that have a column containing certain text, but I need these rows to be synced both ways, so that if a contributor changes something in one of the two sheets, it is reflected in the other. Also I need that if new rows meeting the same criteria are added, they should be reported in the other sheet dynamically as well. I know it should be doable with Apps Script but I have no idea where to start from.



Solution 1:[1]

Two way sync for user edit of single cells only

function onEdit(e) {
  const sh = e.range.getSheet();
  const names = ['Sheet0','Sheet1'];//Sheet names
  const idx = names.indexOf(sh.getName());
  if(~idx) {
    const rA1 = e.range.getA1Notation();
    const shts = names.map(name => e.source.getSheetByName(name));
    shts.filter(s => shts.indexOf(s) != idx).forEach(s => s.getRange(rA1).setValue(e.value));
  }
}

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Cooper