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).


No comments:

Post a Comment