Anthology CSV parse update. Backed up Supplier Prod's templates.
This commit is contained in:
@ -6,9 +6,9 @@ function main() {
|
||||
while (files.hasNext()) {
|
||||
var file = files.next();
|
||||
var getDate = new Date();
|
||||
var date = Utilities.formatDate(getDate, 'America/New_York', 'MM/dd/yyyy hh');
|
||||
var date = Utilities.formatDate(getDate, 'America/New_York', 'MM/dd/yyyy hh:mm');
|
||||
var fileDate = file.getDateCreated();
|
||||
var fileDateFormatted = Utilities.formatDate(fileDate, 'America/New_York', 'MM/dd/yyyy hh');
|
||||
var fileDateFormatted = Utilities.formatDate(fileDate, 'America/New_York', 'MM/dd/yyyy hh:mm');
|
||||
if (date == fileDateFormatted) {
|
||||
Logger.log("Updated: "+file)
|
||||
var updated_file = file.getBlob()
|
||||
@ -34,10 +34,10 @@ function moveOldFiles() {
|
||||
while (files.hasNext()) {
|
||||
var file = files.next();
|
||||
var getDate = new Date();
|
||||
var date = Utilities.formatDate(getDate, 'America/New_York', 'MM/dd/yyyy hh' );
|
||||
var date = Utilities.formatDate(getDate, 'America/New_York', 'MM/dd/yyyy hh:mm' );
|
||||
var fileDate = file.getDateCreated();
|
||||
Logger.log("FILE: "+file+", DATE UPLOADED: "+fileDate)
|
||||
var fileDateFormatted = Utilities.formatDate(fileDate, 'America/New_York', 'MM/dd/yyyy hh');
|
||||
var fileDateFormatted = Utilities.formatDate(fileDate, 'America/New_York', 'MM/dd/yyyy hh:mm');
|
||||
if (date != fileDateFormatted) {
|
||||
const destination = DriveApp.getFolderById('1cIPZCgoj8XdjMIfL75QfomJAxsy2smGT');
|
||||
file.moveTo(destination);
|
||||
@ -144,12 +144,9 @@ function updatedDomainsOnly(domains_to_update) {
|
||||
const dom = array.shift();
|
||||
const groups = array;
|
||||
Logger.log("{domain_to_update : {domain :"+dom+", group_ids : "+groups+" }}")
|
||||
sendWebhook({domain_to_update : { domain: dom, group_ids: groups }})
|
||||
//sendWebhook({domain_to_update : { domain: dom, group_ids: groups }})
|
||||
replaceOnSheet(dom, groups);
|
||||
}
|
||||
// MailApp.sendEmail("nrasmussen@gainsight.com",
|
||||
// "Anthology has submitted a CSV",
|
||||
// "Here are the domains that will be updated: "+JSON.stringify(noErrorObj)+"\n\n"+"Group Errors (they likely don't exist): "+JSON.stringify(errorList));
|
||||
MailApp.sendEmail("amitd@anthology.com",
|
||||
"Anthology has submitted a CSV",
|
||||
"Here are the domains that will be updated: "+JSON.stringify(noErrorObj)+"\n\n"+"Group Errors (they likely don't exist): "+JSON.stringify(errorList));
|
||||
@ -165,13 +162,14 @@ function replaceOnSheet(dom, groups) {
|
||||
|
||||
let boo = sheet.createTextFinder(dom).findNext()
|
||||
if (boo != null ) {
|
||||
//Logger.log("Replace on Sheet Domain: "+dom)
|
||||
//Logger.log("New groups: "+groups)
|
||||
Logger.log("Replace on Sheet Domain: "+dom)
|
||||
Logger.log("New groups: "+groups)
|
||||
group2 = []
|
||||
currCell = boo.getRowIndex();
|
||||
groups.forEach(item => { if (item.length > 0) { group2.push(item) }});
|
||||
group2 = [group2];
|
||||
//Logger.log(group2);
|
||||
Logger.log(group2);
|
||||
sheet.getRange(currCell, 1, 1, 100).clear();
|
||||
sheet.getRange(currCell, 1).setValue(dom);
|
||||
sheet.getRange(currCell, 2, 1, group2[0].length).setValues(group2)
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user