Google Scripts for Talkspace & Doximity. SOme walmart notes
This commit is contained in:
@ -1,9 +1,9 @@
|
||||
/*
|
||||
This script sends a daily reminder to the Sales and Marketing channel as to which
|
||||
lines of data are unclean and not filled out. Currently, it is only pulling from the last 5 days.
|
||||
This will be sent out between 3-4pm so that AEs can get their data in and clean before EOD.
|
||||
/*
|
||||
This script sends a daily reminder to the Sales and Marketing channel as to which
|
||||
lines of data are unclean and not filled out. Currently, it is only pulling from the last 5 days.
|
||||
This will be sent out between 3-4pm so that AEs can get their data in and clean before EOD.
|
||||
Any questions or changes needed, see Norm.
|
||||
Webhook URL in this sheet is for #sales-n-marketing channel.
|
||||
Webhook URL in this sheet is for #sales-n-marketing channel.
|
||||
*/
|
||||
// Setup of the sheet
|
||||
const sheet = SpreadsheetApp.getActiveSheet();
|
||||
@ -22,11 +22,11 @@ var meetingCount = 0;
|
||||
var finalAEList;
|
||||
var tagUsers;
|
||||
|
||||
/*
|
||||
/*
|
||||
This function will create two empty arrays, one for the list of missed entries and one for tagging users in Slack
|
||||
First, the function gets the data ranges in spreadsheed and adds those columns to an array index.
|
||||
Second, the for loop cycles through the super long array (4 results per line). Based on the if statement,
|
||||
the loop removes all arrays that don't fit the statement.
|
||||
the loop removes all arrays that don't fit the statement.
|
||||
*/
|
||||
function findMeetings() { // Setting up data range and empty arrays
|
||||
var startRow = 2; // First row of data to process
|
||||
@ -43,12 +43,12 @@ function findMeetings() { // Setting up data range and empty arrays
|
||||
var date = Utilities.formatDate(row[3],'America/New_York','MM/dd/yyyy'); // Column - D
|
||||
var company = row[4]; // Column - E
|
||||
let missedEntries = [name, date, company, attended];
|
||||
/*
|
||||
Adding a For Loop will pull a result for EACH element, aka 4 results per line.
|
||||
/*
|
||||
Adding a For Loop will pull a result for EACH element, aka 4 results per line.
|
||||
This pulls one for each group of missedEntries
|
||||
This then removes the last value (attended, since we already know it is a blank), converts to a string,
|
||||
and adds to a new array. The counter will compare if there is more than one entry in the array.
|
||||
*/
|
||||
and adds to a new array. The counter will compare if there is more than one entry in the array.
|
||||
*/
|
||||
if ((missedEntries[3] == "") && (missedEntries[1] >= formatWeek) && (missedEntries[1] <= formatNow)) {
|
||||
meetingCount += 1;
|
||||
missedEntries.pop();
|
||||
@ -57,10 +57,10 @@ function findMeetings() { // Setting up data range and empty arrays
|
||||
//Logger.log(slackingAEListOne);
|
||||
};
|
||||
};
|
||||
/* Now outside of the if statement:
|
||||
/* 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 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');
|
||||
@ -95,8 +95,8 @@ function findMeetings() { // Setting up data range and empty arrays
|
||||
tagList.push('<@U0325CWA3N3>');
|
||||
}
|
||||
var tagUsers = tagList.toString();
|
||||
/*
|
||||
Now, we're building the payload for the Slack Message.
|
||||
/*
|
||||
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/
|
||||
|
||||
@ -169,7 +169,7 @@ function findMeetings() { // Setting up data range and empty arrays
|
||||
// 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",
|
||||
method: "post",
|
||||
contentType: "application/json",
|
||||
muteHttpExceptions: true,
|
||||
payload: JSON.stringify(payloadText),
|
||||
@ -179,10 +179,10 @@ function findMeetings() { // Setting up data range and empty arrays
|
||||
//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.
|
||||
This is the else statement that sends a certain message not tagging anyone and saying that data is clean.
|
||||
*/
|
||||
} else {
|
||||
let noMeetingMsg =
|
||||
let noMeetingMsg =
|
||||
{
|
||||
"blocks": [
|
||||
{
|
||||
@ -204,7 +204,7 @@ function findMeetings() { // Setting up data range and empty arrays
|
||||
// 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",
|
||||
method: "post",
|
||||
contentType: "application/json",
|
||||
muteHttpExceptions: true,
|
||||
payload: JSON.stringify(noMeetingMsg),
|
||||
|
||||
Reference in New Issue
Block a user