TL;DR:
Novice with JavaScript and in need of assistance in joining multiple data sources and then updating only specific records while limiting updated cells to only 'new' information.
Any pointers on syntax to control/manage order of execution are appreciated. Mainly to ensure everything happens in the same order, every time.
Long Version:
Hello All!
I'm a novice when it comes to Apps Script (and by extension JavaScript), and I'm wondering if anyone has it in their heart of hearts to lend me a hand for a few minutes.
Background: I'm working on automating one of our on-going tasks that tracks incident reports and on-going updates in monthly snapshots.
Issue: In an attempt to better explain what I'm trying to do, I've employed a (very) modified version of syntax loosely based on (my limited knowledge of) JS.
The general order of operations is below. I know there are some steps missing that would be in the actual code, but I did that for what I hope is a more simple explanation.
Prior to executing any JS to take care of requisite housekeeping work, I run an existing sql query to capture updated information from a DB
var Q = updated query results
var NEW = new sheet/tab containing data from Q
var OLD = existing (static) report (last month)
var TEMP = new sheet/tab
create NEW;
join OLD with NEW in TEMP;
SORT TEMP ('A2:A!') by col1;
UPDATE ('A:!') in col5-col10 with NEW;
// only update cell with NEW data if data in NEW is different that data in OLD
IF data in NEW (!=) OLD; // I think this is how that is written...
For a visual example, here is what I'm thinking:
I am already thankful for your time to read this far. If you think you can / have time to walk me through this, I would GREATLY appreciate it!
Cheers!