Search code examples
javascriptgoogle-forms

Populating a Google Form from a script running on another website


I have a Google Form (under my control), and a loaded script (my control) on a non-Google website (not under my control). The script collects data from objects on the third-party website, and I'd like to be able to make a URL to a form that is pre-populated with data from the 3rd party site.

For example: Run the script, collect name and description fields from the 3rd party site Popup a banner with a clickable link, which open a Google Form with the name and description fields populated, so the user can then add what's missing and press send.

I see other solutions that use FormApp.openByUrl('http://googleform_etc');. FormApp seems to be a Google specific function. How to do this on the 3rd party site with JavaScript?


Solution

  • That method, FormApp.openByUrl(), is indeed a Google Apps Script function. Google does not provide another API for forms.

    However, the Apps Script Execution API provides a way for your JavaScript to authenticate with Google's servers and invoke scripts that utilize authorized Google Apps services. You would provide the Google Apps Script to generate the URL for a pre-populated form, for example, and invoke it through gapi.client.request.

    See the JavaScript Quickstart to begin.