You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

调用setCollectEmail(true)后,如何用Google Apps Script禁用Google表单的Response receipt?

How to Disable Auto-Enabled Response Receipts When Using setCollectEmail(true) in Google Apps Script

Hey there, I’ve been in your exact situation before—super annoying when Google Forms forces that response receipt toggle on automatically, and the native FormApp service doesn’t give you a straightforward way to turn it off. Let me walk you through the workaround I found:

The Problem

When you call form.setCollectEmail(true) in Apps Script, Google Forms automatically enables the "Response receipt" option for respondents. Unfortunately, the basic FormApp library doesn’t include a direct method to disable this. To fix this, we need to use the Google Forms API (a more powerful, advanced tool) to tweak that setting.

Step 1: Enable the Forms API in Your Script Project

First, you need to turn on the Forms API for your Apps Script project:

  • Open your script editor, go to Extensions > Apps Script.
  • Click on Services > Add Service, find Forms API in the list, and click Add.
    • Note: This will also enable the API in your linked Google Cloud Console project, but if you run into permission issues later, double-check that the Forms API is enabled there too.

Step 2: Write the Code to Disable Response Receipts

Here’s a reusable function that uses the Forms API to turn off the response receipt setting. Call this right after enabling email collection:

// Helper function to disable response receipts for a given form
function disableResponseReceipt(formId) {
  const updateRequests = [{
    updateSettings: {
      settings: {
        enableResponseReceipts: false
      },
      updateMask: "enableResponseReceipts"
    }
  }];

  // Send the update request to the Forms API
  Forms.Forms.batchUpdate({ requests: updateRequests }, formId);
}

// Example: Create a form and disable auto-enabled response receipts
function createCustomForm() {
  // Create your form as usual
  const newForm = FormApp.create("My Custom Form");
  
  // Enable email collection (this turns on receipts by default)
  newForm.setCollectEmail(true);
  
  // Immediately disable the response receipt setting
  disableResponseReceipt(newForm.getId());
}

How It Works

  • The updateSettings request targets the enableResponseReceipts setting and sets it to false.
  • The updateMask tells the API exactly which setting we want to modify, so it doesn’t touch any other form configurations.

Quick Notes

  • Make sure your script has the necessary permissions to modify the form—when you run the function for the first time, you’ll be prompted to authorize it.
  • If you’re modifying an existing form instead of creating a new one, just pass the existing form’s ID to disableResponseReceipt().

内容的提问来源于stack exchange,提问作者Arthur CROS

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.27 06:51:39