diff --git a/About.html b/About.html index 8f75cc7..ddcf930 100644 --- a/About.html +++ b/About.html @@ -1,5 +1,9 @@
+ This version of Form Notifications is a fork of Form Notifications (https://github.com/googlesamples/apps-script-form-notifications-addon). + It added the possibility to add the form content to the respondent notification email so that the end-user has a copy of what he filled out. +
Form Notifications was created as an sample add-on, and is meant for demonstration purposes only. It should not be used for complex or diff --git a/Code.gs b/Code.gs index 8a4f32a..bece9c0 100644 --- a/Code.gs +++ b/Code.gs @@ -128,7 +128,8 @@ function adjustFormSubmitTrigger() { var settings = PropertiesService.getDocumentProperties(); var triggerNeeded = settings.getProperty('creatorNotify') == 'true' || - settings.getProperty('respondentNotify') == 'true'; + settings.getProperty('respondentNotify') == 'true' || + settings.getProperty('sendContentsToRespondent') == 'true' ; // Create a new trigger if required; delete existing trigger // if it is not needed. @@ -271,19 +272,33 @@ function sendRespondentNotification(response) { var settings = PropertiesService.getDocumentProperties(); var emailId = settings.getProperty('respondentEmailItemId'); var emailItem = form.getItemById(parseInt(emailId)); + var contentString = ""; + if(settings.getProperty('sendContentsToRespondent') == 'true') { + contentString += "Your response was: \n"; + var itemResponses = response.getItemResponses(); + for (var j = 0; j < itemResponses.length; j++) { + var itemResponse = itemResponses[j]; + // Logger.log('Response #%s to the question "%s" was "%s"', (i + 1).toString(), itemResponse.getItem().getTitle(), itemResponse.getResponse()); + contentString += " " + String(itemResponse.getItem().getTitle()) + ": " + String(itemResponse.getResponse()) + "\n"; + }; + contentString += "\n"; + } else { + contentString += "Your response is not included.\n"; + } var respondentEmail = response.getResponseForItem(emailItem) .getResponse(); if (respondentEmail) { var template = HtmlService.createTemplateFromFile('RespondentNotification'); template.paragraphs = settings.getProperty('responseText').split('\n'); + template.responseData = contentString.split('\n'); template.notice = NOTICE; var message = template.evaluate(); MailApp.sendEmail(respondentEmail, settings.getProperty('responseSubject'), - message.getContent(), { + (message.getContent()), { name: form.getTitle(), - htmlBody: message.getContent() + htmlBody: (message.getContent()) }); } } diff --git a/README.md b/README.md index c594485..66ff88b 100644 --- a/README.md +++ b/README.md @@ -3,6 +3,11 @@ Form Notifications Add-on for Google Forms A sample Google Apps Script add-on for Google Forms. +This version is a fork of Form Notifications +(https://github.com/googlesamples/apps-script-form-notifications-addon). +It added the possibility to add the form content to the respondent +notification email so that the end-user has a copy of what he filled out. + Introduction ------------ @@ -81,4 +86,4 @@ software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations -under the License. \ No newline at end of file +under the License. diff --git a/RespondentNotification.html b/RespondentNotification.html index a20234d..834d4c9 100644 --- a/RespondentNotification.html +++ b/RespondentNotification.html @@ -2,6 +2,13 @@
= paragraphs[i] ?>
} ?> + += responseData[i] ?>
+ } ?> +This automatic message was sent to you via the Form
diff --git a/Sidebar.html b/Sidebar.html
index eb77e6d..51ab30c 100644
--- a/Sidebar.html
+++ b/Sidebar.html
@@ -6,28 +6,23 @@
bottom: 54px;
top: 0;
}
-
.branding-text {
left: 7px;
position: relative;
top: 3px;
}
-
.logo {
vertical-align: middle;
}
-
.width-100 {
width: 100%;
box-sizing: border-box;
-webkit-box-sizing : border-box;
-moz-box-sizing : border-box;
}
-
label {
font-weight: bold;
}
-
#creator-options,
#respondent-options {
background-color: #eee;
@@ -36,18 +31,15 @@
border-style: solid;
display: none;
}
-
#creator-email,
#respondent-email,
#button-bar,
#submit-subject {
margin-bottom: 10px;
}
-
#response-step {
display: inline;
}
-