Skip to content

Commit 2ca605b

Browse files
committed
fix: Delint previous change
1 parent 136b6f2 commit 2ca605b

File tree

1 file changed

+68
-70
lines changed
  • solutions/automations/employee-certificate

1 file changed

+68
-70
lines changed

solutions/automations/employee-certificate/Code.js

Lines changed: 68 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -17,68 +17,67 @@ See the License for the specific language governing permissions and
1717
limitations under the License.
1818
*/
1919

20-
let slideTemplateId = "PRESENTATION_ID";
21-
let tempFolderId = "FOLDER_ID"; // Create an empty folder in Google Drive
20+
const slideTemplateId = 'PRESENTATION_ID';
21+
const tempFolderId = 'FOLDER_ID'; // Create an empty folder in Google Drive
2222

2323
/**
2424
* Creates a custom menu "Appreciation" in the spreadsheet
2525
* with drop-down options to create and send certificates
2626
*/
2727
function onOpen(e) {
28-
let ui = SpreadsheetApp.getUi();
28+
const ui = SpreadsheetApp.getUi();
2929
ui.createMenu('Appreciation')
30-
.addItem('Create certificates', 'createCertificates')
31-
.addSeparator()
32-
.addItem('Send certificates', 'sendCertificates')
33-
.addToUi();
30+
.addItem('Create certificates', 'createCertificates')
31+
.addSeparator()
32+
.addItem('Send certificates', 'sendCertificates')
33+
.addToUi();
3434
}
3535

3636
/**
3737
* Creates a personalized certificate for each employee
3838
* and stores every individual Slides doc on Google Drive
3939
*/
4040
function createCertificates() {
41-
4241
// Load the Google Slide template file
43-
let template = DriveApp.getFileById(slideTemplateId);
44-
42+
const template = DriveApp.getFileById(slideTemplateId);
43+
4544
// Get all employee data from the spreadsheet and identify the headers
46-
let sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
47-
let values = sheet.getDataRange().getValues();
48-
let headers = values[0];
49-
let empNameIndex = headers.indexOf("Employee Name");
50-
let dateIndex = headers.indexOf("Date");
51-
let managerNameIndex = headers.indexOf("Manager Name");
52-
let titleIndex = headers.indexOf("Title");
53-
let compNameIndex = headers.indexOf("Company Name");
54-
let empEmailIndex = headers.indexOf("Employee Email");
55-
let empSlideIndex = headers.indexOf("Employee Slide");
56-
let statusIndex = headers.indexOf("Status");
57-
45+
const sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
46+
const values = sheet.getDataRange().getValues();
47+
const headers = values[0];
48+
const empNameIndex = headers.indexOf('Employee Name');
49+
const dateIndex = headers.indexOf('Date');
50+
const managerNameIndex = headers.indexOf('Manager Name');
51+
const titleIndex = headers.indexOf('Title');
52+
const compNameIndex = headers.indexOf('Company Name');
53+
const empEmailIndex = headers.indexOf('Employee Email');
54+
const empSlideIndex = headers.indexOf('Employee Slide');
55+
const statusIndex = headers.indexOf('Status');
56+
5857
// Iterate through each row to capture individual details
5958
for (let i = 1; i < values.length; i++) {
60-
let rowData = values[i];
61-
let empName = rowData[empNameIndex];
62-
let date = rowData[dateIndex];
63-
let managerName = rowData[managerNameIndex];
64-
let title = rowData[titleIndex];
65-
let compName = rowData[compNameIndex];
66-
59+
const rowData = values[i];
60+
const empName = rowData[empNameIndex];
61+
const date = rowData[dateIndex];
62+
const managerName = rowData[managerNameIndex];
63+
const title = rowData[titleIndex];
64+
const compName = rowData[compNameIndex];
65+
6766
// Make a copy of the Slide template and rename it with employee name
68-
let tempFolder = DriveApp.getFolderById(tempFolderId);
69-
let empSlideId = template.makeCopy(tempFolder).setName(empName).getId();
70-
let empSlide = SlidesApp.openById(empSlideId).getSlides()[0];
71-
67+
const tempFolder = DriveApp.getFolderById(tempFolderId);
68+
const empSlideId = template.makeCopy(tempFolder).setName(empName).getId();
69+
const empSlide = SlidesApp.openById(empSlideId).getSlides()[0];
70+
7271
// Replace placeholder values with actual employee related details
73-
empSlide.replaceAllText("Employee Name", empName);
74-
empSlide.replaceAllText("Date", "Date: " + Utilities.formatDate(date, Session.getScriptTimeZone(), "MMMM dd, yyyy"));
75-
empSlide.replaceAllText("Your Name", managerName);
76-
empSlide.replaceAllText("Title", title);
77-
empSlide.replaceAllText("Company Name", compName);
78-
72+
empSlide.replaceAllText('Employee Name', empName);
73+
empSlide.replaceAllText('Date', 'Date: ' + Utilities.formatDate(date, Session.getScriptTimeZone(), 'MMMM dd, yyyy'));
74+
empSlide.replaceAllText('Your Name', managerName);
75+
empSlide.replaceAllText('Title', title);
76+
empSlide.replaceAllText('Company Name', compName);
77+
7978
// Update the spreadsheet with the new Slide Id and status
8079
sheet.getRange(i + 1, empSlideIndex + 1).setValue(empSlideId);
81-
sheet.getRange(i + 1, statusIndex + 1).setValue("CREATED");
80+
sheet.getRange(i + 1, statusIndex + 1).setValue('CREATED');
8281
SpreadsheetApp.flush();
8382
}
8483
}
@@ -88,46 +87,45 @@ function createCertificates() {
8887
* with a PDF attachment of their appreciation certificate
8988
*/
9089
function sendCertificates() {
91-
9290
// Get all employee data from the spreadsheet and identify the headers
93-
let sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
94-
let values = sheet.getDataRange().getValues();
95-
let headers = values[0];
96-
let empNameIndex = headers.indexOf("Employee Name");
97-
let dateIndex = headers.indexOf("Date");
98-
let managerNameIndex = headers.indexOf("Manager Name");
99-
let titleIndex = headers.indexOf("Title");
100-
let compNameIndex = headers.indexOf("Company Name");
101-
let empEmailIndex = headers.indexOf("Employee Email");
102-
let empSlideIndex = headers.indexOf("Employee Slide");
103-
let statusIndex = headers.indexOf("Status");
104-
91+
const sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
92+
const values = sheet.getDataRange().getValues();
93+
const headers = values[0];
94+
const empNameIndex = headers.indexOf('Employee Name');
95+
const dateIndex = headers.indexOf('Date');
96+
const managerNameIndex = headers.indexOf('Manager Name');
97+
const titleIndex = headers.indexOf('Title');
98+
const compNameIndex = headers.indexOf('Company Name');
99+
const empEmailIndex = headers.indexOf('Employee Email');
100+
const empSlideIndex = headers.indexOf('Employee Slide');
101+
const statusIndex = headers.indexOf('Status');
102+
105103
// Iterate through each row to capture individual details
106104
for (let i = 1; i < values.length; i++) {
107-
let rowData = values[i];
108-
let empName = rowData[empNameIndex];
109-
let date = rowData[dateIndex];
110-
let managerName = rowData[managerNameIndex];
111-
let title = rowData[titleIndex];
112-
let compName = rowData[compNameIndex];
113-
let empSlideId = rowData[empSlideIndex];
114-
let empEmail = rowData[empEmailIndex];
115-
105+
const rowData = values[i];
106+
const empName = rowData[empNameIndex];
107+
const date = rowData[dateIndex];
108+
const managerName = rowData[managerNameIndex];
109+
const title = rowData[titleIndex];
110+
const compName = rowData[compNameIndex];
111+
const empSlideId = rowData[empSlideIndex];
112+
const empEmail = rowData[empEmailIndex];
113+
116114
// Load the employee's personalized Google Slide file
117-
let attachment = DriveApp.getFileById(empSlideId);
118-
115+
const attachment = DriveApp.getFileById(empSlideId);
116+
119117
// Setup the required parameters and send them the email
120-
let senderName = "CertBot";
121-
let subject = empName + ", you're awesome!";
122-
let body = "Please find your employee appreciation certificate attached."
123-
+ "\n\n" + compName + " team";
118+
const senderName = 'CertBot';
119+
const subject = empName + ', you\'re awesome!';
120+
const body = 'Please find your employee appreciation certificate attached.' +
121+
'\n\n' + compName + ' team';
124122
GmailApp.sendEmail(empEmail, subject, body, {
125123
attachments: [attachment.getAs(MimeType.PDF)],
126124
name: senderName
127125
});
128-
126+
129127
// Update the spreadsheet with email status
130-
sheet.getRange(i + 1, statusIndex + 1).setValue("SENT");
128+
sheet.getRange(i + 1, statusIndex + 1).setValue('SENT');
131129
SpreadsheetApp.flush();
132130
}
133131
}

0 commit comments

Comments
 (0)