0

I've searched all over Google's documentation on this topic and I haven't been able to find a tutorial or article that explains how to do this. I completely understand how to create simple triggers in a project.

I'm trying to populate a ListItem in a Google Form with information that is based on the user using the form. My understanding is that a simple onOpen trigger will not be triggered by users other than the owner of the script, hence my need to use "installable triggers". Please correct me if I'm wrong.

How do you set up an installable onOpen trigger within a script project?

  • Where does it say how to set them up? – 02fentym Nov 24 '17 at 21:17
3

Direct answer.

To create an installable triggers, open Script Editor (Tools > Script Editor in Spreadsheets or Documents, or in "three dots" menu in Google Forms). Within it go to Edit > Current project's triggers. A pop-up window will appear, listing the current triggers (if any) and prompting you to create a new one.

"On open" in a form

The above will not help because what you are trying to do is impossible. For a form "on open" means the form is opened for editing. This is true for both simple and installable triggers. There is no trigger for "someone opened the form to fill it up. You cannot modify the contents of the form based on who opened it.

Other remarks

a simple onOpen trigger will not be triggered by users other than the owner of the script

This is incorrect. I use simple onOpen triggers to create custom menu items in shared spreadsheets, and they work for every user with access to the spreadsheet.

  • Not only the title. "How do you set up an installable onOpen trigger within a script project?" is the last sentence of question body. Sure, this question has some serious XYZUVW problem... – user135384 Nov 24 '17 at 22:04
  • Final question. Let's say there are two ListItems on a form (ListItem1 and ListItem2). Is there a way to dynamically update ListItem2 based on a selection made for ListItem1? – 02fentym Nov 24 '17 at 22:37
  • 1
    @02fentym Not really: Is it possible to show dynamic information in a Google Form based on a previous response?. The best you can do is to set up multiple "sections" (previously called "pages") and direct user to an appropriate section based on the item they picked. See Set up specific questions to appear only after particular answers on Google Forms. – user135384 Nov 24 '17 at 23:01
  • There is another question on SO called "Can I dynamically update the contents of a Google Forms listbox" and one of the commenters says that some updateForm function can do the job. So that's not true? – 02fentym Nov 24 '17 at 23:17
  • 1
    @02fentym Well, that answer is scored -2 for a reason (I just added another downvote). All it shows is that a script can change the form; no big discovery there. That a script cannot respond to a user opening a form, for lack of a suitable trigger, is not mentioned. – user135384 Nov 25 '17 at 0:41
3

Short answer

It's not possible to populate a Google Form ListItem based on the user using the form as respondent.

Explanation

Google Forms has two main views:

  • Editor view: Available to the form owner and editors.
  • Respondent view: Available to "anyone" with the respondent view link

The available installable triggers are Form Open and Form Submit. From https://developers.google.com/apps-script/guides/triggers/events, regarding the Form Open simple and installable event:

  • This event does not occur when a user opens a form to respond, but rather when an editor opens the form to modify it.

The above means that the Form Open trigger can only be used with the owner and editor of the form when they use the editor view.

Note: G Suite Google Form users could limit the respondent view to users from the same G Suite organization.

  • I'll try to explain this as best as I can. I need to know the email of the person using the form so that I can do a look up on a google sheet. Once I look up info on the sheet based on that person's email, I want to populate a ListItem on the form. I figured that since there's an onOpen function that I could use that event to trigger all of this. I'm already dynamically filling in values in other ListItem objects. – 02fentym Nov 24 '17 at 21:56
  • What I mean by "the person using the form" is the user of the form. It could be me...it could be one of my colleagues. This form is for a school, so a bunch of teachers will be using it. We're GAFE customers so I believe that I have a G Suite account. – 02fentym Nov 24 '17 at 22:02
  • Isn't onOpen triggered when the form is opened? – 02fentym Nov 24 '17 at 22:11
  • Ah...ok. That's too bad. Thanks for the info. I must have misread the doc. – 02fentym Nov 24 '17 at 22:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.