Javascript - There are multiple operations not synced to the server

Hi
I am using following Javascript to calculate the level of a hierarchy.

// get table by name
const table = base.getTableByName('B.Capability'); 
const table2 = base.getTableByName('B.Capability');
// get view by name
const view = base.getViewByName(table, 'Default');
const view2 = base.getViewByName(table2, 'Default');
// get rows via table and view
const rows = base.getRows(table, view);
const rows2 = base.getRows(table2, view2);
// iterate and print

//Level 0
for (var i=0; i<rows.length; i++) {
  const row = rows[i];
  if (row['Parent'] == "") {
    base.modifyRow(table, row, {'Level': '0'});
  }
}

//Level 1
for (var i=0; i<rows.length; i++) {
  const row = rows[i];
  if (row['Parent'] != "") {
    for (var x=0; x<rows2.length; x++) {
      const row2 = rows2[x];
      if (row['Parent'] == row2['_id'] && row2['Level'] == 0) {
        base.modifyRow(table, row, {'Level': 1});
        //output.text(row2['Name']+ ' ' + row2['Level']);
      }
    }
  }
}

// Level 2
const rows3 = base.getRows(table2, view2);
for (var i=0; i<rows.length; i++) {
  const row = rows[i];
  if (row['Parent'] != "") {
    for (var x=0; x<rows3.length; x++) {
      const row3 = rows3[x];
      if (row['Parent'] == row3['_id'] && row3['Level'] == 1) {
        base.modifyRow(table, row, {'Level': 2});
        //output.text("Level2");
      }
    }
  }
}

// Level 3
const rows4 = base.getRows(table2, view2);
for (var i=0; i<rows.length; i++) {
  const row = rows[i];
  if (row['Parent'] != "") {
    for (var x=0; x<rows4.length; x++) {
      const row4 = rows4[x];
      if (row['Parent'] == row4['_id'] && row4['Level'] == 2) {
        base.modifyRow(table, row, {'Level': 3});
        //output.text("Level3");
      }
    }
  }
}

// Level 4
const rows5 = base.getRows(table2, view2);
for (var i=0; i<rows.length; i++) {
  const row = rows[i];
  if (row['Parent'] != "") {
    for (var x=0; x<rows5.length; x++) {
      const row5 = rows5[x];
      if (row['Parent'] == row5['_id'] && row5['Level'] == 3) {
        base.modifyRow(table, row, {'Level': 4});
        //output.text("Level4");
      }
    }
  }
}

// Level 5
const rows6 = base.getRows(table2, view2);
for (var i=0; i<rows.length; i++) {
  const row = rows[i];
  if (row['Parent'] != "") {
    for (var x=0; x<rows6.length; x++) {
      const row6 = rows6[x];
      if (row['Parent'] == row6['_id'] && row6['Level'] == 4) {
        base.modifyRow(table, row, {'Level': 5});
        //output.text("Level4");
      }
    }
  }
}

Since 2.2, may already with 2.1 when running Javascript it gives following error message multiple times:

There are multiple operations not synced to the server. Please check your network.

The script works and levels are calculated correctly, but it gives error messages.

Hi, this warning is a result of the JavaScript generating a lot of operations. The warnings will be reduced in the next 2.3 release.

Sorry for the inconvenience - but 2.3 will be released in a week or two!

Ok, thank you for the information! :+1:

You are welcome! Since this is a known issue and it doesn’t affect the calculation result, I’m marking this post as resolved.

1 Like