Keiro Kamioka Keiro Kamioka - 1 year ago 70
JSON Question

How do I insert the updated [non-null] value as the new row on another sheet?

Updated 10/10 22:46 PST

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

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.
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.

Answer Source

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()).

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download