Skip to content

Instantly share code, notes, and snippets.

View [Scripts for Bug Reporter Form] test()
function test() {
Logger.log("[METHOD] test");
var ssResponses = SpreadsheetApp.getActive().getSheetByName("Form responses 1");
var testRange = ssResponses.getRange(2,1,1,ssResponses.getLastColumn());
sendEmail(testRange);
}
View [Scripts for Bug Reporter Form] shortenPriorityText(text)
function shortenPriorityText(text) {
Logger.log("[METHOD] shortenPriorityText");
switch(text) {
case "Critical = Bug is already producing consequences":
return "CRITICAL";
case "High = Consequences will come with delay":
return "HIGH";
case "Regular = Needs to be done":
return "REGULAR";
View [Scripts for Bug Reporter Form] sendEmail(range) – PREPARE EMAIL
var emailRecipients = "ken@madebymany.com";
var emailSubject = bugPriority+": "+bugName+" ("+bugEmail+")";
var emailBody = "<h3>A bug has been reported by "+bugEmail+":</h3><hr /> \
<p> \
<h1 style='line-height:90%'>"+bugPriority+": "+bugName+"<br /> \
<span style='font-size:60%'>("+bugDate+")</span></h1> \
</p><hr /> \
<p> \
<strong>BUG TYPE:</strong><br /> \
"+bugType+" \
View [Scripts for Bug Reporter Form] sendEmail(range) – CLEAN VARIABLES
bugPriority = shortenPriorityText(bugPriority);
if (bugAdditionalInfo.length == 0) bugAdditionalInfo = "None";
var bugFollowUp = "";
if (bugScreenshots.length != 0) bugFollowUp = bugFollowUp.concat("<li>Ask for screenshots or additional files</li>");
if (bugEmailUpdates.length != 0) bugFollowUp = bugFollowUp.concat("<li>Provide status updates to "+bugEmail+"</li>");
if (bugFollowUp.length == 0) bugFollowUp = "<br />None";
else bugFollowUp = "<ul>"+bugFollowUp+"</ul>";
View [Scripts for Bug Reporter Form] sendEmail(range) – EXTRACT VALUES
var bugPriority = row[2];
var bugName = row[3];
var bugEmail = row[1];
var bugDate = row[0];
var bugType = row[5];
var bugDescription = row[4];
var bugSteps = row[6];
var bugExpectedBehavior = row[7];
var bugMacOS = row[9];
var bugWindows = row[10];
View [Scripts for Bug Reporter Form] sendEmail(range) – TEMPLATE
function sendEmail(range) {
Logger.log("[METHOD] sendEmail");
// FETCH SPREADSHEET //
// EXTRACT VALUES //
// CLEAN VARIABLES //
// PREPARE EMAIL //
View [Scripts for Bug Reporter Form] ALL FUNCTIONS
function onFormSubmit(e) {
Logger.log("[METHOD] onFormSubmit");
sendEmail(e.range);
}
function sendEmail(range) {
Logger.log("[METHOD] sendEmail");
var values = range.getValues();
View [Scripts for Bug Reporter Form] onFormSubmit(e)
function onFormSubmit(e) {
Logger.log("[METHOD] onFormSubmit");
sendEmail(e.range);
}