Tuesday, 28 October 2025

Publish a Google Form to your domain

The following Google Apps Script is designed to publish a Google Form to your domain only, for completion.

Screenshot of code for publishing a Google Form
Screenshot of code for publishing a Google Form

Enable Drive API

Please follow the steps to enable the 'Drive API' Service (V3) if you are not working from a copy of the file in this post.


The Code

Setting the Form to be published first is the key step in this process, something that was missing from the Google support articles at the time of writing:

FormApp.openById(formId).setPublished(true);

Next we create the necessary configuration for the Drive API to take our domain as the scope for those we want to complete our Form:

var options = {

    domain: "YOUR DOMAIN HERE",

    type: "domain",

    role: "reader",

    view: "published",

};

Finally, we add an option for Shared drive compatibility, then make the API call:

var optionalArgs = {

    supportsAllDrives: true

};

Drive.Permissions.create(options, formId, optionalArgs); 


Download

Publish a Google Form to your domain download (please use 'Overview' > 'Make a copy' for your own version of the Apps Script file).


2 comments:

  1. Thanks for this..

    Does this code enable a google form stored on your Drive to be accessible via a link from a website?

    Or can it be made visible in the website using something like an iframe?

    It would be interesting to see an implementation

    Tom (very occasional google app script coder)

    ReplyDelete
    Replies
    1. Hi

      Yes once the Form has been published you can share its link practically anywhere.

      If you click 'Send' on a Google Form there is also a "Embed HTML" option.

      Delete