Skip to content

Commit

Permalink
bulk_upload.gs: If not all of the records' primary keys are empty, re…
Browse files Browse the repository at this point in the history
…place those that are with 0s

This allows the upload to proceed: the affected rows will be part of the unmatched people export.
  • Loading branch information
solb committed Jun 21, 2020
1 parent 1a341cf commit a91c298
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions bulk_upload.gs
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,8 @@ function doGet(ter) {

// Time to actually remove the unwanted columns, then add the vanId one.
var vanidx = -1;
var unkeyed = false;
var unkeyed = 0;
var records = 0;
var datadump = '';
csv = csv.replace(/^[^"\n]+/mg, function(line) {
var fields = line.split(',');
Expand All @@ -195,13 +196,15 @@ function doGet(ter) {
if(id)
id = id.replace(/^.+(\d{10})$/, '$1');
else if(fields[0]) {
unkeyed = true;
id = '0';
++unkeyed;
datadump += '<br>' + JSON.stringify({ fields: fields, vanidx: vanidx, id: id });
}
++records;
return id + ',' + line;
});

if(unkeyed)
if(unkeyed == records)
return HtmlService.createHtmlOutput('Data file missing primary key column: \'' + vanid + '\':' + datadump)
.setXFrameOptionsMode(HtmlService.XFrameOptionsMode.ALLOWALL);

Expand Down

0 comments on commit a91c298

Please sign in to comment.