Last active
November 30, 2022 18:13
-
-
Save DerekCaelin/fb13d85e4bcd503217cc5793c27dfc08 to your computer and use it in GitHub Desktop.
Google Form to Trello Board via Email
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
If you want entries on a Google form to auto-create a Trello card, | |
you can follow the steps below. | |
There are two ways to connect a Google form to a Trello board. One of them | |
involves using the Trello API. This version instead works by sending an email to a | |
Trello board's private email address and then it creates cards based off the content | |
of the email. | |
Trello will make a card with a title that matches the "subject" line of the | |
email. The description will match the message within the email. | |
1. Create a Google form with a number of questions. | |
2. In the settings of the Google form, select "< > Script Editor" | |
3. Replace the pre-existing text with the text from this form. | |
4. Adapt the code: | |
- Replace the email adress that the script will send to with the email address you find on the Trello board. (Menu > More > Email-to-Board Settings) | |
- Change the content of the email message. | |
5. On the code page, go to Resources > Edit > All Your Triggers. Add a new trigger that runs onFormSubmit. (This will run the "onFormSubmit" function in your code when someone clicks "Submit" on the Google Form. | |
6. When prompted, provide necessary permissions for your google script to send emails on your behalf, etc. | |
*/ | |
//Form Variables | |
var form; //this is your Google form | |
var responses; //is a collection of all the responses that are provided by the goolge form | |
//Google Form responses | |
//these are the individual responses that come with your form. Change the number of your what. | |
var entry1; | |
var entry2; | |
var entry3; | |
//email content | |
var trelloEmail = "[email protected]"; //This is the email address of your trello board. | |
var trelloTitle; //This is the Subject Line of the email your script will send. | |
var trelloDescription; //This is the Body of the email your script will send. | |
function onFormSubmit(e) { | |
form = FormApp.getActiveForm(); | |
responses = e.response.getItemResponses(); | |
//assign variables | |
AssignVariables (); | |
//build email | |
BuildEmail(); | |
//send email | |
SendEmail(); | |
} | |
//Get the value of variables from the form | |
function AssignVariables(form){ | |
entry1 = responses[0].getResponse(); | |
entry2 = responses[1].getResponse(); | |
entry3 = responses[2].getResponse(); | |
} | |
function BuildEmail(){ | |
trelloTitle = 'Google Form Entry'; | |
trelloDescription = 'Values from your Google form include: ' + '\n' + entry1 + ', ' + entry2 + ', ' + entry3 + '.'; | |
} | |
function SendEmail(){ | |
MailApp.sendEmail(trelloEmail, title, message); | |
} |
How can I get the form submitted time in Trello card ?
Unless I am misunderstanding this code, there's a mistake in the SendEmail function. The function sends an email using the email address provided in the code, but the variables "title" and "message" are not defined variables for the function call. Should it instead have trelloTitle and trelloDescription in place of those two variables?
It looks like there's a similar error in the AssignVariables function and its use. The function requests the variable "form", but in the function call, no value is given. In the execution of the function, it instead uses only the responses variable and doesn't require the input variable. This also means that fetching the form variable is unnecessary.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi there (code noobie here)
I am getting the following error : TypeError: Cannot read property 'response' of undefinedonFormSubmit @ Code.gs:18
Can you maybe please advice?