Walmart notes. Zenjob Assignment Script backed up. Reorged some directories.
This commit is contained in:
1
Scripts/GAS_NP/Sheets_to_Jira/.clasp.json
Normal file
1
Scripts/GAS_NP/Sheets_to_Jira/.clasp.json
Normal file
@ -0,0 +1 @@
|
||||
{"scriptId":"1VUbCbC6whkodvYSfTSmaFCNVxowtahxUHaKcr7Dg_Ly0vevBLqlDWmdS","rootDir":"/Users/normrasmussen/Documents/Northpass/Google_Scripts/Sheets_to_Jira"}
|
||||
108
Scripts/GAS_NP/Sheets_to_Jira/IntoJira.js
Normal file
108
Scripts/GAS_NP/Sheets_to_Jira/IntoJira.js
Normal file
@ -0,0 +1,108 @@
|
||||
/* Pertinent Information and Codes:
|
||||
Custom Fields:
|
||||
Channel = customfield_10121
|
||||
Campaign = customfield_10120
|
||||
SDR = customfield_10122
|
||||
Start Date = customfield_10015
|
||||
|
||||
Prior to making this publicly available, I added a commented list of users & their account numbers.
|
||||
|
||||
Without accounts: Adan, Drew
|
||||
|
||||
*/
|
||||
function myFunction() {
|
||||
var URL = "https://your_company.atlassian.net/rest/api/3/issue/";
|
||||
var token = "api_toke_goes_here";
|
||||
var user = "user@company.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" :
|
||||
"account_num_goes_here",
|
||||
"Nick" :
|
||||
"account_num_goes_here",
|
||||
"Appleby" :
|
||||
"account_num_goes_here",
|
||||
"Doug" :
|
||||
"account_num_goes_here",
|
||||
"Quba" :
|
||||
"account_num_goes_here",
|
||||
};
|
||||
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/GAS_NP/Sheets_to_Jira/appsscript.json
Normal file
7
Scripts/GAS_NP/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