From ca8e66eb00203b8f8f36ab205e001122e026be48 Mon Sep 17 00:00:00 2001 From: Norm Rasmussen Date: Thu, 24 Feb 2022 09:18:06 -0500 Subject: [PATCH] changes --- Google_Scripts/.AE_Reminders_Daily.gs.swp | Bin 16384 -> 0 bytes Google_Scripts/AE_Reminders_Daily.gs | 216 +++++++++++++++------- Google_Scripts/Sheets>Jira.gs | 207 +++++++++++++-------- 3 files changed, 272 insertions(+), 151 deletions(-) delete mode 100644 Google_Scripts/.AE_Reminders_Daily.gs.swp diff --git a/Google_Scripts/.AE_Reminders_Daily.gs.swp b/Google_Scripts/.AE_Reminders_Daily.gs.swp deleted file mode 100644 index c26df6e924bfdd48fc5d0cec8b5bc3af902ac554..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 16384 zcmeHOU2I%O6}|}sNTC!FluCfaWFxw})_Q;J#7W#bVdM2r9ovb$o203+oY{M4cdz&E zo!dM2db274Bwj!W0S}dUfd`Q23p`ZtfLe(s5QV2 zMJs{OUHS8R=gyotbN*)LoOQE&3Sf3`Y*WbG%G<;$=aa@C8K z5=>6$E1WPq($35XksssX2C*Vqz7Nl%@VykY4 zZh!~Xxvh24bA3mIYOBUwZ%}Nj19a1dR0634-b4a%)EYnkpfx#BDO1nWnN#e<2d}@$ zp!9Jnfm8yi1X2m45=bSGN+6X$DuGl2|4$N#f}_@Fu%M&KqHZVeNA|tHBl(<7-f!=F zo_tK-QVFCINF|U;AeBHWfm8yi1X2m45=bSGN+6X$DuMq&32?`|m;{aiM}gOo^mq+; z1$Y_wG4KQ6o4^{d3@iY%KoQ6T9|s-+jsmYCsq!4~9pG8uTfmoq&jQ=PDd3~P!@vpP zAJD-c0IiEe5C8Goae8Hagluf%SxlT))j69*F|uzQb(U3%EZ>2)(WR zWFBv^fsC`EU=eS(g;Su9tiyMNpN&|{^*rG)H)1l5ikY{EgONxbcgMx|Qi$yR|5nJ)5Ldix(e#vu%5OU z^F+h~KJX-W8c-^mK^uNLQ52}@Qi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;AErV5u-rDJ!v}gc+B0@>2p+H)STzh9LQeE8OsJqe zM90<;r`Xvz3?Y1PP)PP1b4)%9KY$!!gc*-r!&ZSlIMu**p*HQ@n65sunW&0GJVa83 zi|vRyIX?xD{XFP_7Ty29f;;yj?&5U+&n6enXK>&DGH@4Y1Gj*Sz=wb%0ObOH0jvV! zKn^$!d<=L1I0hU6UPWHuSHO!v9|!>-=mH(!B=8(^1YZX}57@vQ@Dbo7@Cx|)9`HHf z3P5}=0O>20Kq`S$0;vR238WH8C6G!WmB4>f0y?9%EK!6A@!zlQ98T%MtaJo&88~>? zL^DPnTjI2iyTLFwjw>P+Mi|mTqj5OfJ1eTaZy1jHEjR2jdW!yZr5R3uqkl3+rvWf6 zt_6aoHW`EDmSD)zH7E4uMPzsAlF*_*a(&V4;2(E!B@CznWRiS(J#3hEpJq$-tE)wm z>T+9y+^!Nro^H3u2O^idh$_O|9a|VW(<};OVV;5uh)~%_^)P?4DbLGO-?n+Rbe{$gonMrcC!zu@I2EM~X-0YDB z0Moby>pX@NQ{4&IH@ad|E8Xmdbqcz+qfmf$y-W-8JiduikuIq1t*YT_ZE6-Ulm>4r zQ%ut-XMNqK3=NVm$PDPqBN8B^WVcRf*U2bMneHuC*A7+N!UY<7+j5-@G=&U)B>i#I zmei`^(4$8~tvJ$F#kT&xZe3Kmm)yWVcsr$vELS?)7vxo0T|d(hOLv~A#ns96bIrxo z=3w^nq~Hrnv43T1TyD2Z!f~V1ZP%G8vrn0f3fosWGbPUB8J*fCHWZcEw&>oEvf381 z>D{f$#AMRV6gg4gM0$POMR&4TEz42OGjrb>T|(ntkrm|w*Wc2$Qe8Y9(a@FFd;N^i z%0cO|z5}t-N*UX{_sgg=&kFur= formatWeek) && (missedEntries[1] <= formatNow)) { + meetingCount += 1; missedEntries.pop(); missedEntries.toString(); slackingAEListOne.push(missedEntries); + //Logger.log(slackingAEListOne); }; }; - // Now outside of the if statement: - // the array is built, and we want each group to be on a new line, remove the commas and add a hyphen. - var slackingAEListTwo = slackingAEListOne.splice(1).join('\n'); - var finalAEList = slackingAEListTwo.replace(/,/g, ' - ') - + /* Now outside of the if statement: + the array is built, and we want each group to be on a new line, remove the commas and add a hyphen. + The counter counts if there is 1 or more meetings, or not. If 0, it sends a certain message, not tagging anyone. + If it is one or more, it splices by the first array (index 0), adds a new line, and replaces commans with hyphens. + */ + if (meetingCount >= 1) { + var slackingAEListTwo = slackingAEListOne.splice(0).join('\n'); + var finalAEList = slackingAEListTwo.replace(/,/g, ' - '); // This if statement is going to only tag those who appear in the previous list. // No need to tag people who have done their work and contribute to clean data. if (finalAEList.includes('Norm')) { @@ -57,79 +79,133 @@ function findMeetings() { // Setting up data range and empty arrays if (finalAEList.includes('Charles')) { tagList.push('<@U01286MQUS2>'); } - var tagUsers = tagList.toString(); - - /* Now, we're building the payload for the Slack Message. + if (finalAEList.includes('Travis')) { + tagList.push('<@UFE3T14UX>'); + } + if (finalAEList.includes('Nick')) { + tagList.push('<@U0276LMA70F>'); + } + if (finalAEList.includes('Mike')) { + tagList.push('<@U027MAQUPM0>'); + } + var tagUsers = tagList.toString(); + /* + Now, we're building the payload for the Slack Message. This is very specific and prone to errors, so check that it works using Slack's tool: - https://app.slack.com/block-kit-builder/ */ - - let payloadText = + https://app.slack.com/block-kit-builder/ + + Copy from Rich: + ":rotating_light::rotating_light::rotating_light: New Meeting Tracker Alert! :rotating_light::rotating_light::rotating_light: + It's your daily reminder to update the new meeting tracker. + If you've been tagged, please address this by EOD." + */ + let payloadText = { - "blocks": [ + "blocks": [ + { + "type": "section", + "text": { + "type": "mrkdwn", + "text": ":rotating_light::rotating_light::rotating_light: New Meeting Tracker Alert! :rotating_light::rotating_light::rotating_light:" + } + }, + { + "type": "section", + "text": { + "type": "mrkdwn", + "text": "It's your daily reminder to update the new meeting tracker." + } + }, + { + "type": "section", + "text": { + "type": "mrkdwn", + "text": "If you've been tagged, please address this by EOD." + } + }, + { + "type": "section", + "text": { + "type": "mrkdwn", + "text": finalAEList // Sends list with AE, meeting date, and company + } + }, + { + "type": "section", + "text": { + "type": "mrkdwn", + "text": "In case you need it, here's a link to the sheet. :point_right:" + }, + "accessory": { + "type": "button", + "text": { + "type": "plain_text", + "text": "Sales New Meeting Tracker", + "emoji": true + }, + "value": "sales_tracker_link_123", + "url": "https://docs.google.com/spreadsheets/d/150nSuHQLJHpJaYdQ6KHeN7nQ6iexwtnQEpicM77PK8A/edit#gid=0 | First Meeting Tracker", + "action_id": "button-action" + } + }, + { + "type": "divider" + }, + { + "type": "section", + "text": { + "type": "mrkdwn", + "text": tagUsers // Tags with slack user numbers if they appear in finalSend + } + } + ] +}; + // This is standard operating procedure to creating the payload and destination + const webhook = "https://hooks.slack.com/services/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"; + const options = { + method: "post", + contentType: "application/json", + muteHttpExceptions: true, + payload: JSON.stringify(payloadText), + }; + const sendMsg = UrlFetchApp.fetch(webhook, options); + var respCode = sendMsg.getResponseCode(); + //Logger.log(sendMsg); // Debug to confirm send + //Logger.log(respCode); // Debug to show errors, if any + /* + This is the else statement that sends a certain message not tagging anyone and saying that data is clean. + */ + } else { + let noMeetingMsg = + { + "blocks": [ { "type": "section", "text": { "type": "mrkdwn", - "text": ":bell: *Have you filled out the Sales New Meeting Tracker?* :bell:" - } - }, - { - "type": "divider" - }, - { - "type": "section", - "text": { - "type": "mrkdwn", - "text": "If you're tagged, you haven't filled it out." + "text": ":star::star::star: New Meeting Tracker Alert! :star::star::star:" } }, { "type": "section", "text": { "type": "mrkdwn", - "text": finalAEList // Sends list with AE, meeting date, and company - } - }, - { - "type": "section", - "text": { - "type": "mrkdwn", - "text": "Here, a convenient link to the sheet!:point_right: :point_right: :point_right: :point_right:" - }, - "accessory": { - "type": "button", - "text": { - "type": "plain_text", - "text": "Sales New Meeting Tracker", - "emoji": true - }, - "value": "sales_tracker_link_123", - "url": "https://docs.google.com/spreadsheets/d/1o01hj9oOoAR4TeJxXDuA3R7bHNbyCB3eaGJunK6-ojg/edit#gid=0 | First Meeting Tracker", - "action_id": "button-action" - } - }, - { - "type": "divider" - }, - { - "type": "section", - "text": { - "type": "mrkdwn", - "text": tagUsers // Tags with slack user numbers if they appear in finalSend + "text": "Good job, everyone! All meetings from the last 5 days are up to date. Keep doing what you're doing!" } } ] }; - // This is standard operating procedure to creating the payload and destination - const webhook = "https://hooks.slack.com/services/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"; - const options = { - method: "post", - contentType: "application/json", - muteHttpExceptions: true, - payload: JSON.stringify(payloadText), - }; - const sendMsg = UrlFetchApp.fetch(webhook, options); - var respCode = sendMsg.getResponseCode(); - Logger.log(sendMsg); // Debug to confirm send - Logger.log(respCode); // Debug to show errors, if any -}; +// This is standard operating procedure to creating the payload and destination + const webhook = "https://hooks.slack.com/services/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"; + const options = { + method: "post", + contentType: "application/json", + muteHttpExceptions: true, + payload: JSON.stringify(noMeetingMsg), + }; + const sendMsg = UrlFetchApp.fetch(webhook, options); + var respCode = sendMsg.getResponseCode(); + //Logger.log(sendMsg); // Debug to confirm send + //Logger.log(respCode); // Debug to show errors, if any +} +}; \ No newline at end of file diff --git a/Google_Scripts/Sheets>Jira.gs b/Google_Scripts/Sheets>Jira.gs index 798bf43c..e4c5e0c4 100644 --- a/Google_Scripts/Sheets>Jira.gs +++ b/Google_Scripts/Sheets>Jira.gs @@ -1,86 +1,131 @@ +/* Pertinent Information and Codes: +Custom Fields: +Channel = customfield_10121 +Campaign = customfield_10120 +SDR = customfield_10122 +Start Date = customfield_10015 + +Users: +Travis Nardin = 5d9cb42c0265ca0db955b965 +Dan Peski = 603318815ddf020069969cad +Norm Rasmussen = 6092af20d353800068863d15 +Michael Valido = 61fbf60cd8d7cf006a90941c +Jon Newfield = 6092af212c2f6c0068ec92c4 +Isabel Katz = 620145241fec260068c107e5 +Charles McGovern = 5eaaf1c4021ae30ba8fcb184 +Nick Zuppe = 60eddda64257a90070aeebef +Doug Goldsmith = 61294a4845f753006951a590 +Nick Appleby = 6183eab7892c420072f9c437 +Quba Williams-Wilfong = 62101fe4e41f76006a6f6510 + +Without accounts: Adan, Drew + +*/ +var count = 0; +var list; +var finalEntry; + function myFunction() { - var URL = "https://northpass.atlassian.net/rest/api/2/issue"; - var accountID = "6092af20d353800068863d15"; - var token = "2NrKYv22TLWnxTo7EhU3633E"; - var UserCredentials = "Basic " + Utilities.base64Encode(accountID+":"+token); + var URL = "https://northpass.atlassian.net/rest/api/3/issue/"; + // var accountID = "6092af20d353800068863d15"; + var token = "2NrKYv22TLWnxTo7EhU3633E"; + // var UserCredentials = Utilities.base64Encode(accountID + ":" + token); + var user = "nrasmussen@northpass.com"; + // var pass = "c9QK\>4^fxiHt!"; + var UserCredentials = Utilities.base64Encode(user + ":" + token); - // Setting up data range and empty arrays - const sheet = SpreadsheetApp.getActiveSheet(); + // Setting up data range and empty arrays + const sheet = SpreadsheetApp.getActiveSheet(); + var startRow = 244; // First col of data to process + var numRows = 450; // Number of rows to process + var dataRange = sheet.getRange(startRow, 1, numRows, sheet.getLastColumn()).getValues(); + var data = dataRange.filter(function(r){ + return r.join("").length>0; + }); + var sdr = ""; - for (i in data) { // For a data row within the entire data range - var startRow = 2; // First row of data to process - var numRows = sheet.getLastRow()-1; // Number of rows to process - var dataRange = sheet.getRange(startRow, 1, numRows, sheet.getLastColumn()); - var data = dataRange.getValues(); - let row = data[i]; - let name = row[1]; // Column - B - var meetingDate = Utilities.formatDate(row[3],'America/New_York','MM/dd/yyyy'); // Column - D - var company = row[4]; // Column - E - let list = [name, company, meetingDate]; - - if (list[0] == "Norm") { - Logger.log(list) - var data = { - "fields": { - "project" : { - "key" : "2NrKYv22TLWnxTo7EhU3633E" - }, - "summary" : list[1], - "description" : "Meeting scheduled for " + list[3], - "date" : list[3], - "issuetype": { - "name" : Task - } + for (i in data) { // For a data col within the entire data range + var col = data[i]; + let sdr = col[0]; // Column - A + let name = col[1]; // Column - B + let rawDate = Utilities.formatDate(col[3], 'America/New_York', 'yyyy-MM-dd'); + let bookingDate = Utilities.formatDate(col[2], 'America/New_York', 'MM/dd/yyyy'); // Column - C + let meetingDate = Utilities.formatDate(col[3], 'America/New_York', 'MM/dd/yyyy'); // Column - D + let company = col[4]; // Column - E + let channel = col[5]; // Column - F + let result = col[7]; // Column - H + let campaign = col[8]; // Column - I + let info = col[9]; // Column - J + let list = [sdr, name, rawDate ,bookingDate, meetingDate, company, channel, result, campaign, info]; + list.toString(); + let sdrDict = { + "Mike" : + "61fbf60cd8d7cf006a90941c", + "Nick" : + "60eddda64257a90070aeebef", + "Appleby" : + "6183eab7892c420072f9c437", + "Doug" : + "61294a4845f753006951a590", + "Quba" : + "62101fe4e41f76006a6f6510", + }; + if (list.includes("Norm")) { + var data = { + "fields": { + "project": { + "key": "NORMPIPE", + }, + "issuetype": { + "id": "10268", + }, + "summary": list[5], + "description": { + "type": "doc", + "version": 1, + "content": [ + { + "type": "paragraph", + "content": [ + { + "type": "text", + "text": "Booked Date - " + list[3] + '\n' + + "Meeting Date - " + list[4] + '\n' + + "Description from Tracker: " + list[9] + '\n' + + "Last Status - " + list[7] } - }; - }; - }; - - var payload = JSON.stringify(data); - - var headers = { "Accept":"application/json", - "Content-Type":"application/json", - "Authorization":UserCredentials, - "muteHttpExceptions":"True" - } - var options = { "method":"POST", - "headers": headers, - "payload": payload - }; - - var response = UrlFetchApp.fetch(URL, options); - Logger.log(response); - -}; - -// LONG JSON -var data = { - "fields": { - "issuetype": { - "id" : "10203" - }, - "parent": { - "key": "NORMPIPE", - "id": "10203", - }, - "project" : { - "id" : "10052", - "key" : "NORMPIPE", - }, - "description" : "Meeting scheduled for " + list[3],{ - "type" : "doc", - "version" : 1, - "content": [ - { - "type": "paragraph", - "content": [ - { - "text" : "Meeting scheduled for " + list[3], - "type" : "text", - } - ] - }, - ] - }, + ] + } + ], + }, + "customfield_10015": list[2], // Start (Meeting) Date - rawDate + "customfield_10120": [ // Campaign + list[8] + ], + "customfield_10122": [{"id" : sdrDict[list[0]]}], // SDR + "customfield_10121": [ // Channel + list[6] + ], + } }, - }; \ No newline at end of file + payload = JSON.stringify(data); + Logger.log(payload); + var headers = { + "Accept": "application/json", + "Content-Type": "application/json", + "Authorization": "Basic " + UserCredentials, + "muteHttpExceptions": true, + } + var options = { + "method": "POST", + "headers": headers, + "payload": payload + } + //Logger.log(options); + var response = UrlFetchApp.fetch(URL, options); + //Logger.log(response); + var respCode = response.getResponseCode(); + //Logger.log(respCode); + } + } +}; \ No newline at end of file