SHARE
TWEET

Untitled

a guest Sep 5th, 2016 76 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*
  2. If you want entries on a Google form to auto-create a Trello card,
  3. you can follow the steps below.
  4.  
  5. There are two ways to connect a Google form to a Trello board. One of them
  6. involves using the Trello API. This version instead works by sending an email to a
  7. Trello board's private email address and then it creates cards based off the content
  8. of the email.
  9.  
  10. Trello will make a card with a title that matches the "subject" line of the
  11. email. The description will match the message within the email.
  12.  
  13. 1. Create a Google form with a number of questions.
  14. 2. In the settings of the Google form, select "< > Script Editor"
  15. 3. Replace the pre-existing text with the text from this form.
  16. 4. Adapt the code:
  17.    - 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)
  18.    - Change the content of the email message.
  19. 5. On the code page, go to Resources > 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.
  20. 6. When prompted, provide necessary permissions for your google script to send emails on your behalf, etc.
  21.  
  22. */
  23.  
  24. //Form Variables
  25. var form; //this is your Google form
  26. var responses; //is a collection of all the responses that are provided by the goolge form
  27.  
  28. //Google Form responses
  29. //these are the individual responses that come with your form. Change the number of your what.
  30. var entry1;
  31. var entry2;
  32. var entry3;
  33.  
  34. //email content
  35. var trelloEmail = "example@email.com"; //This is the email address of your trello board.
  36. var trelloTitle; //This is the Subject Line of the email your script will send.
  37. var trelloDescription; //This is the Body of the email your script will send.
  38.  
  39. function onFormSubmit(e) {
  40.   form = FormApp.getActiveForm();
  41.   responses = e.response.getItemResponses();
  42.  
  43.   //assign variables
  44.   AssignVariables ();
  45.  
  46.   //build email
  47.   BuildEmail();
  48.  
  49.   //send email
  50.   SendEmail();
  51. }
  52.  
  53. //Get the value of variables from the form
  54. function AssignVariables(form){
  55.   entry1 = responses[1].getResponse();
  56.   entry2 = responses[2].getResponse();
  57.   entry3 = responses[3].getResponse();
  58.  
  59. }
  60.  
  61. function BuildEmail(){
  62.   trelloTitle = 'Google Form Entry';
  63.   trelloDescription = 'Values from your Google form include: ' + '\n' + entry1 + ', ' + entry2 + ', ' + entry3 + '.';
  64. }
  65.  
  66. function SendEmail(){
  67.   MailApp.sendEmail(trelloEmail, title, message);
  68. }
RAW Paste Data
Top