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

使用Apps Script结合Google Sheets:获取短链接并提取文件名

Hey there, let's work through that annoying "No item with the given ID could be found, or you do not have permission to access it." error you're facing with your Google Sheets and Apps Script setup.

Troubleshooting the Permission/ID Error in Your Apps Script Setup

Common Causes & Step-by-Step Fixes

  • Permission Mismatches
    • First, double-check that the Google account you're using to run the script has edit access to both the target Google Sheet and the linked form. If you switched accounts recently, or the sheet/form was shared with a view-only role, this is the most likely culprit.
    • For G Suite/Workspace users: Confirm your organization's admin hasn't set policies that block access to sheet/form resources.
  • Invalid Resource IDs
    • This error often pops up when your script references a wrong ID for the sheet, form, or uploaded receipt files.
      • If you hardcoded a sheet ID, cross-verify it with the string in your sheet's URL (the long sequence between /d/ and /edit).
      • If your script pulls IDs dynamically (like form response IDs or receipt image IDs), add a console.log(yourIdVariable); line to the script, run it, and check the Apps Script console to confirm the ID is valid (not null, empty, or a typo).
  • Corrupted Form-Sheet Link
    • Sometimes the connection between your form and sheet breaks quietly. Try refreshing it: Open your form, go to Responses > Link to Sheets, then re-select your existing sheet (or create a temporary one and switch back) to reset the link.
  • Access Issues for Uploaded Receipts
    • If your script interacts with receipt images stored in Google Drive:
      • Ensure the Drive folder holding the receipts is shared with your account (or the script's service account, if using advanced services) with edit permissions.
      • Confirm you're extracting the correct file ID from form responses. File upload fields often return a URL instead of a raw ID—you'll need to parse the URL to grab the ID (e.g., from https://drive.google.com/file/d/[FILE_ID]/view, extract the [FILE_ID] segment).

Code Check Guide (Once You Share Your Script)

When you paste your code, here are key things to look for upfront:

  • Are you using SpreadsheetApp.openById() with the exact, correct sheet ID? No typos or old IDs from deleted sheets allowed.
  • If interacting with the form, does FormApp.openById() use the actual form ID (found in the form's URL)?
  • For receipt uploads: Are you correctly pulling the file ID from the form response object? File upload fields return a blob or file object—you may need to use getFileById() with the ID extracted from that object.

Quick Diagnostic Test

  1. Open your Apps Script editor, pick a simple function (like one that just logs the sheet ID) and run it via Run > Run function. If the error hits immediately, you know the issue is with basic resource access.
  2. Check the Executions tab in the Apps Script editor—it will show you the exact line of code throwing the error, narrowing down which resource ID is causing the problem.

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.20 07:57:12