Autofill google docs from form responses (with a conidition)

46 views
Skip to first unread message

Scott Dillon

unread,
Feb 27, 2022, 4:35:05 PM2/27/22
to Google Apps Script Community
Hello all, I've already created a google script that will autofill a document when a form is submitted. However, I've run into a problem.

What I'm looking to do is create that document only if a particular question in the form response is a particular value. 

For instance, the google form I've created is for creating work orders, but in this application, there is a high chance the work order will be opened and closed at the same time. 

What I'm looking to do is create an option for the work order to be opened of closed. If the form option "open" is selected, I do not want the auto fill document to be created. If the form option "closed" is selected, I want the automation scripting to run. 

If anyone has an idea of how to go about this or what lines of code to use that would be greatly appreciated!

Thanks!

Clark Lind

unread,
Mar 6, 2022, 2:21:10 PM3/6/22
to Google Apps Script Community
I don't know if you found an answer yet, but you can add an onFormSubmit() trigger inside the form (or attached sheet). 
Then you parse the form input looking for that specific item. Then simply add, 

function onFormSubmit(e) {
  if (e.someParameter.item === 'Closed') {
     GenerateWorkorder(e)        //"e" should contain all the form element information
  }
}
Reply all
Reply to author
Forward
0 new messages