1
votes

Updated 10/10 22:46 PST

Hello, I would like to update the question. This is my current sheet.

https://docs.google.com/spreadsheets/d/1JHP6SA77FTIfKRpIXCWmY5xSsfrf3SeCKQe7h7o7970/edit?usp=sharing

From research I attempt to apply the similar script that might help me however, the current script does not seems to work.

And this is my current Google Script code. Every time, when the row 2 from 'UpdateTriggerSheet' update as the non-null value, I would like to insert updated value as the new row in the 'addBook' Sheet.

But does not seems to work. What should I do?

function onEdit(event) {
  var ss = SpreadsheetApp.getActiveSpreadsheet();
  var s = event.source.getActiveSheet();
  var r = event.source.getActiveRange();

  s.getName() == "UpdateTriggerSheet"
  r.getrow() == 2

  if(isBlank() == False) {
    var row = r.getRow();
    var numColumns = s.getLastColumn();
    var targetSheet = ss.getSheetByName("addBook");
    var target = targetSheet.getRange(targetSheet.getLastRow() + 1, 1);
    s.getRange(row, 1, 1, numColumns).moveTo(target);
  }
}

Old question sentence

I currently creating Online Book Shelf with using google sheet. I've create the sheet that will obtain .json from the Japanese Government Library API, after enter ISBN. https://docs.google.com/spreadsheets/d/107mxVkN047VGiFD6Zti2WhefgjcTrzus8NIljg1g0d8/edit?usp=sharing The data I want to keep will display on row 8, at 'GetBookInfo' Sheet. I currently looking for the way, everytime row 8 get updated, I would like to add the updated data as the new row in 'BookShelf' sheet. I assume I can use onUpdate() or onEdit(), to make this possible but not sure how do I code that.

1
Try using an onEdit() installable trigger. See developers.google.com/apps-script/guides/triggers/installableRubén
Thanks for answer. I'll try do better research next time when I try to ask.Sakai Kyoutarou

1 Answers

1
votes

Don't know if isBlank() exists in Javascript, but you can always check if your variable is not null by such a simple condition like if (yourVariable) { your code } — read more here: Is there a standard function to check for null, undefined, or blank variables in JavaScript?

So, your condition in this case should look like this: if (s.getName() == "UpdateTriggerSheet" && r.getRow() == 2 && r.getValue()) for the function to work (and don't forget to change a couple of getrow() to getRow()).