omnisend, scripts organization
This commit is contained in:
1
Scripts/Sheets_to_Jira/.clasp.json
Normal file
1
Scripts/Sheets_to_Jira/.clasp.json
Normal file
@ -0,0 +1 @@
|
||||
{"scriptId":"1VUbCbC6whkodvYSfTSmaFCNVxowtahxUHaKcr7Dg_Ly0vevBLqlDWmdS","rootDir":"/Users/normrasmussen/Documents/Northpass/Google_Scripts/Sheets_to_Jira"}
|
||||
119
Scripts/Sheets_to_Jira/IntoJira.js
Normal file
119
Scripts/Sheets_to_Jira/IntoJira.js
Normal file
@ -0,0 +1,119 @@
|
||||
/* 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
|
||||
|
||||
*/
|
||||
function myFunction() {
|
||||
var URL = "https://northpass.atlassian.net/rest/api/3/issue/";
|
||||
var token = "2NrKYv22TLWnxTo7EhU3633E";
|
||||
var user = "nrasmussen@northpass.com";
|
||||
var UserCredentials = Utilities.base64Encode(user + ":" + token);
|
||||
|
||||
// Setting up data range and empty arrays
|
||||
const sheet = SpreadsheetApp.getActiveSheet();
|
||||
var startRow = 2; // First col of data to process
|
||||
var numRows = 1132; // Number of rows to process
|
||||
var dataRange = sheet.getRange(startRow, 1, numRows, sheet.getLastColumn()).getValues();
|
||||
|
||||
for (col in dataRange) { // For a data col within the entire data range
|
||||
var col = dataRange[col];
|
||||
let sdr = col[0]; // Column - A
|
||||
let name = col[1]; // Column - B
|
||||
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 rawDate = Utilities.formatDate(col[3], "America/New_York", "yyyy-MM-dd");
|
||||
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];
|
||||
let sdrDict = {
|
||||
"Mike" :
|
||||
"61fbf60cd8d7cf006a90941c",
|
||||
"Nick" :
|
||||
"60eddda64257a90070aeebef",
|
||||
"Appleby" :
|
||||
"6183eab7892c420072f9c437",
|
||||
"Doug" :
|
||||
"61294a4845f753006951a590",
|
||||
"Quba" :
|
||||
"62101fe4e41f76006a6f6510",
|
||||
};
|
||||
if (list.includes("Norm")) {
|
||||
var data = {
|
||||
"fields": {
|
||||
"project": {
|
||||
"key": "NPIPE",
|
||||
},
|
||||
"issuetype": {
|
||||
"id": "10275",
|
||||
},
|
||||
"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]
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
},
|
||||
"customfield_10015": list[2], // Start (Meeting) Date - rawDate
|
||||
"customfield_10127": [ // Campaign
|
||||
list[8],
|
||||
],
|
||||
"customfield_10128": [ // Channel
|
||||
list[6],
|
||||
],
|
||||
"customfield_10129": [{"id" : sdrDict[list[0]]}], // SDR
|
||||
}
|
||||
},
|
||||
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);
|
||||
}
|
||||
}
|
||||
};
|
||||
7
Scripts/Sheets_to_Jira/appsscript.json
Normal file
7
Scripts/Sheets_to_Jira/appsscript.json
Normal file
@ -0,0 +1,7 @@
|
||||
{
|
||||
"timeZone": "America/New_York",
|
||||
"dependencies": {
|
||||
},
|
||||
"exceptionLogging": "STACKDRIVER",
|
||||
"runtimeVersion": "V8"
|
||||
}
|
||||
Reference in New Issue
Block a user