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

特定用户无法使用google.script.run调用Google Apps Script函数的问题

Possible Causes & Fixes for google.script.run Failure in Specific Users

First, update your failure handler to capture exact error details—this will help pinpoint the issue. Modify your TestWindow.html script:

<script>
  function testHtml(){
    google.script.run
      .withSuccessHandler(() => window.alert("Success!"))
      .withFailureHandler(error => {
        window.alert(`Failed: ${error.message}\nError Stack: ${error.stack}`);
        console.error(error); // Log to browser console for deeper insights
      })
      .testFunction();
  }
</script>

Ask the problematic users to run this and share the error message/stack trace—this will narrow down the root cause immediately.

Common Chrome/User Settings Issues to Check

Google Apps Script relies on third-party cookies to establish communication between the HTML modal and script backend. If users have strict cookie settings:

  • Have them navigate to Chrome Settings > Privacy and security > Cookies and other site data
  • Enable "Allow all cookies", or add google.com and script.google.com to the "Sites that can always use cookies" list
  • Note: Incognito mode blocks third-party cookies by default—test in regular mode first.

2. Interfering Chrome Extensions

Privacy or ad-blocking extensions often block google.script.run API calls:

  • Ask users to disable all extensions temporarily (Chrome > Extensions > Manage Extensions > Toggle off all)
  • Test the button again. If it works, re-enable extensions one by one to identify the culprit.
  • Common culprits: uBlock Origin, Privacy Badger, AdGuard, or any extension blocking cross-site requests.

3. Corrupted Browser Profile or Cached Data

Outdated cached assets or a corrupted profile can break script execution:

  • Have users clear Chrome's cache and site data: Settings > Privacy and security > Clear browsing data > Check "Cached images and files" and "Cookies and other site data" > Clear data
  • If that fails, ask them to create a new Chrome user profile and test the script from there.

4. Google Workspace Admin Restrictions

If these users are on a corporate Google Workspace account:

  • Check with your admin for organizational policies restricting Apps Script execution, specifically google.script.run in Spreadsheet modals.
  • Admin settings may block certain script APIs or restrict access to attached scripts even if surface-level permissions look correct.

5. Disabled JavaScript or Custom CSP

Ensure users haven't disabled JavaScript:

  • Go to Chrome Settings > Privacy and security > Site Settings > JavaScript > Confirm "Allowed (recommended)" is selected
  • Also, check for custom Content Security Policy (CSP) extensions that might block inline scripts (your current HTML uses inline script, which is allowed by Apps Script's default CSP, but some extensions override this).

Additional Tests

  • Have users try the script in a different browser (Firefox, Edge) to rule out Chrome-specific issues.
  • Double-check that users have edit access to the spreadsheet—even if permissions seem identical, view-only access can break script execution.

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.10 14:30:46