Skip to content

Commit 982563c

Browse files
authored
Update Docs (#1)
* Update Code.gs Update code comments * Update NoV8.gs Update code comments
1 parent cba1e62 commit 982563c

File tree

2 files changed

+33
-33
lines changed

2 files changed

+33
-33
lines changed

Code.gs

+20-20
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
*/
2323

2424
/*
25-
* This function adds a 'Purchase Request Workflow' menu to the Workflow Sheet when opened
25+
* This function adds a 'Purchase Request Workflow' menu to the workflow Sheet when opened
2626
*/
2727
function onOpen() {
2828
const ui = SpreadsheetApp.getUi(); // Sheet UI
@@ -52,7 +52,7 @@ class Workflow {
5252
}
5353

5454
/*
55-
* This static method populates the Workflow Sheet's 'Config' sheet with workflow
55+
* This static method populates the workflow Sheet's 'Config' tab with workflow
5656
* asset URLs and associates the workflow Form destination with the workflow Sheet
5757
*/
5858
static configure() {
@@ -63,7 +63,7 @@ class Workflow {
6363
/*
6464
* This static method generates a new purchase request document from a form submission,
6565
* replaces template markers, shares document with requester/supervisor and sends email notification
66-
* @param {Object} e - event object passed to onSubmit function
66+
* @param {Object} e - event object passed to the form submit function
6767
*/
6868
static generate(e) {
6969
const workflow = new Workflow();
@@ -84,18 +84,18 @@ class Workflow {
8484
if (viewers.emails.length > 0) {
8585
requestFile.addViewers(viewers.emails).setSharing(DriveApp.Access.PRIVATE, DriveApp.Permission.VIEW);
8686
}
87-
// Update workflow request range in form submission sheet
87+
// Update workflow request range in form submission tab
8888
workflow.updateWorkflowFields_(e.range.getRow(), [[requestFile.getUrl(), 'New', '', workflow.getFormattedDate_(date, "M/d/yyyy k:mm:ss")]]);
89-
// Generate notification email body and send to requester/supervisor/business owner
89+
// Generate notification email body and send to requester, supervisor and Sheet owner
9090
email = `New Purchase Request from: <strong>${viewers.requester.name}<\/strong><br><br>
9191
See request document <a href="${doc.getUrl()}">here<\/a>`;
9292
viewers.emails.push(Session.getEffectiveUser().getEmail());
9393
workflow.sendNotification_(viewers.emails, `New ${doc.getName()}`, email);
9494
}
9595

9696
/*
97-
* This static method adds additional fields and formatting to the form submission sheet
98-
* and setups the form submit trigger
97+
* This static method adds additional fields and formatting to the form submission tab
98+
* and sets up the form submit trigger
9999
* @param {string} triggerFunction - name of trigger function to execute on form submission
100100
*/
101101
static initialize(triggerFunction = 'Workflow.generate') {
@@ -106,7 +106,7 @@ class Workflow {
106106

107107
/*
108108
* This static method updates the purchase request document with status updates
109-
* from form submission sheet highlighted row and sends email notification
109+
* from form submission tab highlighted row and sends email notification
110110
*/
111111
static update() {
112112
const workflow = new Workflow();
@@ -130,7 +130,7 @@ class Workflow {
130130
// Update workflow request range 'Last Update' cell with formatted timestamp
131131
activeRowValues[0][3] = workflow.getFormattedDate_(date, "M/d/yyyy k:mm:ss");
132132
workflow.updateWorkflowFields_(activeRowRange.getRow(), activeRowValues);
133-
// Generate notification email body and send to requester, supervisor and to Sheet owner
133+
// Generate notification email body and send to requester, supervisor and Sheet owner
134134
email = `Purchase Request Status Update: <strong>${activeRowValues[0][1]}<\/strong><br><br>
135135
See request document <a href="${doc.getUrl()}">here<\/a>`;
136136
workflow.sendNotification_(recipients.join(','), `Updated Status: ${doc.getName()}`, email);
@@ -158,15 +158,15 @@ class Workflow {
158158
}
159159

160160
/*
161-
* This method adds additional fields and formatting to the form submission sheet and setups the submit trigger
161+
* This method adds additional fields and formatting to the form submission tab and sets up the submit trigger
162162
* @param {string} triggerFunction - name of trigger function to execute on form submission
163163
* @return {Workflow} this object for chaining
164164
*/
165165
initializeRequestSheet_(triggerFunction) {
166166
const self = this, // active spreadsheet
167-
formSheet = self.ss.getSheets()[0]; // form submission sheet - assumes first sheet
167+
formSheet = self.ss.getSheets()[0]; // form submission tab - assumes first location
168168
formSheet.activate();
169-
// Get form submission sheet header row, update background color (yellow) and fold font
169+
// Get form submission tab header row, update background color (yellow) and bold font
170170
formSheet.getRange(1, 1, 1, formSheet.getLastColumn())
171171
.setBackground('#fff2cc')
172172
.setFontWeight('bold');
@@ -196,7 +196,7 @@ class Workflow {
196196

197197
/*
198198
* This method formats a date using the Google Sheet timezone
199-
* @param {Date} date - Javascript date object
199+
* @param {Date} date - Javascript Date object
200200
* @param {string} format - string representing the desired date format
201201
* @return {string} formatted date string
202202
*/
@@ -217,7 +217,7 @@ class Workflow {
217217
let supervisor;
218218
// Shift off header row
219219
employees.shift();
220-
// Find requester who submitted the form request
220+
// Find form submit requester
221221
viewers.requester = employees.filter(row => row[0] === requesterName)
222222
.map((row) => ({ name: row[0], email: row[1], phone: row[2], supervisor: row[3] }))[0];
223223
viewers.emails = viewers.requester.email !== '' ? [viewers.requester.email] : [];
@@ -236,15 +236,15 @@ class Workflow {
236236
}
237237

238238
/*
239-
* This method retrieves the workflow request range of selected row (if selection is valid)
239+
* This method retrieves the workflow request range for selected row (if selection is valid)
240240
* If selection is invalid display a Sheet message
241241
* @return {Range} workflow fields range from active selection
242242
*/
243243
getWorkflowFields_() {
244244
const self = this,
245245
activeSheet = self.ss.getActiveSheet();
246246
let activeRowRange = null, activeRange, activeRowNum;
247-
// Ensure user is on form submission sheet - if not show an error and exit
247+
// Ensure user is on form submission tab - if not show an error and exit
248248
if (activeSheet.getIndex() !== 1) {
249249
self.sendSSMsg_('Select sheet containing purchase requests.', 'Operation Not Valid on Sheet!');
250250
return activeRowRange;
@@ -295,7 +295,7 @@ class Workflow {
295295
}
296296

297297
/*
298-
* This method replaces request document template markers with both values passed from form submission and other data
298+
* This method replaces request document template markers with values passed from form submission and other data
299299
* @param {Document} doc - generated request document
300300
* @param {Object} requestVals - form submission fields
301301
* @param {Object} viewers - requester and supervisor information
@@ -344,7 +344,7 @@ class Workflow {
344344
}
345345

346346
/*
347-
* This method populates the 'Config' sheet with workflow asset URLs
347+
* This method populates the 'Config' tab with workflow asset URLs
348348
* and associates the workflow Form destination with the workflow Sheet
349349
* @return {Workflow} this object for chaining
350350
*/
@@ -358,7 +358,7 @@ class Workflow {
358358
templateDoc = ssFolder.getFilesByType(MimeType.GOOGLE_DOCS).next();
359359
requestForm = ssFolder.getFilesByType(MimeType.GOOGLE_FORMS).next();
360360
requestsFolder = ssFolder.getFolders().next();
361-
// Add workflow asset URLs to ‘Config’ sheet
361+
// Add workflow asset URLs to ‘Config’ tab
362362
self.configSheet.getRange(1, 2, 3).setValues([[requestForm.getUrl()], [templateDoc.getUrl()], [requestsFolder.getUrl()]]);
363363
// Set the workflow Form destination to the workflow Sheet
364364
FormApp.openById(requestForm.getId()).setDestination(FormApp.DestinationType.SPREADSHEET, self.ss.getId());
@@ -385,7 +385,7 @@ class Workflow {
385385
}
386386

387387
/*
388-
* This method updates the selected request workflow range in the form submission sheet
388+
* This method updates the selected request workflow range in the form submission tab
389389
* @param {number} row - selected request row number
390390
* @param {string[][]} vals - two-dimensional array of workflow field values to be written to selected row
391391
* @return {Workflow} this object for chaining

NoV8.gs

+13-13
Original file line numberDiff line numberDiff line change
@@ -52,22 +52,22 @@ function configure(){
5252
templateDoc = ssFolder.getFilesByType(MimeType.GOOGLE_DOCS).next();
5353
requestForm = ssFolder.getFilesByType(MimeType.GOOGLE_FORMS).next();
5454
requestsFolder = ssFolder.getFolders().next();
55-
// Add workflow asset URLs to ‘Config’ sheet
55+
// Add workflow asset URLs to ‘Config’ tab
5656
configSheet.getRange(1, 2, 3).setValues([[requestForm.getUrl()], [templateDoc.getUrl()], [requestsFolder.getUrl()]]);
5757
// Set the workflow Form destination to the workflow Sheet
5858
FormApp.openById(requestForm.getId()).setDestination(FormApp.DestinationType.SPREADSHEET, ss.getId());
5959
}
6060

6161
/*
6262
* This function adds additional fields and formatting to the form submission tab
63-
* and setups the form submit trigger
63+
* and sets up the form submit trigger
6464
*/
6565
function initialize() {
6666
var ss = SpreadsheetApp.getActiveSpreadsheet(), // active spreadsheet
67-
formSheet = ss.getSheets()[0], // form submission tab - assumes first tab
67+
formSheet = ss.getSheets()[0], // form submission tab - assumes first location
6868
triggerFunction = 'generate'; // name of function for submit trigger
6969
formSheet.activate();
70-
// Get form submission sheet header row, update background color (yellow) and fold font
70+
// Get form submission tab header row, update background color (yellow) and bold font
7171
formSheet.getRange(1, 1, 1, formSheet.getLastColumn())
7272
.setBackground('#fff2cc')
7373
.setFontWeight('bold');
@@ -118,10 +118,10 @@ function generate(e) {
118118
if (viewers.emails.length > 0) {
119119
requestFile.addViewers(viewers.emails).setSharing(DriveApp.Access.PRIVATE, DriveApp.Permission.VIEW);
120120
}
121-
// Update workflow request range in form submission sheet
121+
// Update workflow request range in form submission tab
122122
lastupdate = Utilities.formatDate(date, ss.getSpreadsheetTimeZone(), "M/d/yyyy k:mm:ss");
123123
formSheet.getRange(e.range.getRow(), 1, 1, 4).setValues([[requestFile.getUrl(), 'New', '', lastupdate]]);
124-
// Generate notification email body and send to requester/supervisor/business owner
124+
// Generate notification email body and send to requester, supervisor and Sheet owner
125125
email = Utilities.formatString('New Purchase Request from: <strong>%s</strong><br><br>See request document <a href="%s">here<\/a>', viewers.requester.name, doc.getUrl());
126126
viewers.emails.push(Session.getEffectiveUser().getEmail());
127127
GmailApp.sendEmail(viewers.emails, Utilities.formatString('New %s', doc.getName()), '', { htmlBody: email });
@@ -130,13 +130,13 @@ function generate(e) {
130130

131131
/*
132132
* This function updates the purchase request document with status updates
133-
* from form submission sheet highlighted row and sends email notification
133+
* from form submission tab highlighted row and sends email notification
134134
*/
135135
function update() {
136136
var ss = SpreadsheetApp.getActiveSpreadsheet(), // active spreadsheet
137137
configSheet = ss.getSheetByName('Config'), // config tab
138138
employeeSheet = ss.getSheetByName('Employees'), // employees tab
139-
formSheet = ss.getSheets()[0], // form submission sheet - assumes first sheet
139+
formSheet = ss.getSheets()[0], // form submission tab - assumes first location
140140
activeRowRange, activeRowValues, email, date, doc, lastupdate, recipients;
141141
// Create and format date object for 'last update' timestamp
142142
date = new Date();
@@ -156,7 +156,7 @@ function update() {
156156
// Update workflow request range 'Last Update' cell with formatted timestamp
157157
activeRowValues[0][3] = Utilities.formatDate(date, ss.getSpreadsheetTimeZone(), "M/d/yyyy k:mm:ss");
158158
formSheet.getRange(activeRowRange.getRow(), 1, 1, 4).setValues(activeRowValues);
159-
// Generate notification email body and send to requester, supervisor and to Sheet owner
159+
// Generate notification email body and send to requester, supervisor and Sheet owner
160160
email = Utilities.formatString('Purchase Request Status Update: <strong>%s</strong><br><br>See request document <a href="%s">here<\/a>', activeRowValues[0][1], doc.getUrl());
161161
GmailApp.sendEmail(recipients.join(','), Utilities.formatString('Updated Status: %s', doc.getName()), '', { htmlBody: email });
162162
// Display request update message in Sheet
@@ -221,7 +221,7 @@ function getViewers_(employeeSheet, requesterName) {
221221
supervisor;
222222
// Shift off header row
223223
employees.shift();
224-
// Find requester who submitted the form request
224+
// Find form submit requester
225225
viewers.requester = employees.filter(function(row) { return row[0] === requesterName})
226226
.map(function(row) { return { name:row[0], email:row[1], phone:row[2], supervisor:row[3] }})[0];
227227
viewers.emails = viewers.requester.email !== '' ? [viewers.requester.email] : [];
@@ -241,7 +241,7 @@ function getViewers_(employeeSheet, requesterName) {
241241

242242

243243
/*
244-
* This function retrieves the workflow request range of selected row (if selection is valid)
244+
* This function retrieves the workflow request range for selected row (if selection is valid)
245245
* If selection is invalid display a Sheet message
246246
* @return {Range} workflow fields range from active selection
247247
*/
@@ -250,7 +250,7 @@ function getWorkflowFields_() {
250250
activeSheet = ss.getActiveSheet(), // active tab
251251
activeRowRange = null, // active range
252252
activeRange, activeRowNum;
253-
// Ensure user is on form submission sheet - if not show an error and exit
253+
// Ensure user is on form submission rab - if not show an error and exit
254254
if (activeSheet.getIndex() !== 1) {
255255
ss.toast('Select sheet containing purchase requests.', 'Operation Not Valid on Sheet!');
256256
return activeRowRange;
@@ -275,7 +275,7 @@ function getWorkflowFields_() {
275275
}
276276

277277
/*
278-
* This function replaces request document template markers with both values passed from form submission and other data
278+
* This function replaces request document template markers with values passed from form submission and other data
279279
* @param {Document} doc - generated request document
280280
* @param {Object} requestVals - form submission fields
281281
* @param {Object} viewers - requester and supervisor information

0 commit comments

Comments
 (0)