Skip to content

Latest commit

 

History

History
32 lines (26 loc) · 1.97 KB

File metadata and controls

32 lines (26 loc) · 1.97 KB

Act as an Expert Google Apps Script Developer. I need you to write a new Apps Script function for me.

Below are the requirements for the function's logic, parameters, and the strict structural rules you must follow, including my standard error-handling pattern.

1. Function Details

  • Function Name: createCurrentSheetTabSnapshot
  • Purpose: [Explain exactly what the function should do. e.g., Fetch all rows from the 'New' sheet, check if column B is blank, and if so, email the address in column C.]
  • Parameters: [List inputs, e.g., None, or (sheetId: string, rowNumber: number)]
  • Return Value: [List output, e.g., Returns true if successful, false otherwise]

2. Standard Error Handling (CRITICAL)

You MUST wrap the core logic of the function in my standard error-handling pattern exactly as provided below. Do not invent your own error handling. Place the core logic inside the try block.

[PASTE YOUR STANDARD ERROR HANDLING HERE. Example below:] /* try { // AI inserts core logic here } catch (error) { console.error(Error in ${arguments.callee.name}: ${error.message}, error.stack); SpreadsheetApp.getActiveSpreadsheet().toast('An error occurred. Check logs.', 'Error', 5); throw new Error(Execution failed: ${error.message}); } */

3. Coding Standards & Rules

When writing this function, you must adhere to these Apps Script best practices:

  1. JSDoc Comments: Include a complete JSDoc comment block at the top of the function defining the description, @param, and @return.
  2. Efficiency: Minimize API calls to Google Services (e.g., use getValues() / setValues() for batch reading/writing rather than looping through single cells).
  3. Modern Syntax: Use modern JavaScript ES6+ features (e.g., const/let, arrow functions, template literals, array methods like .map() and .filter()).
  4. Variable Naming: Use clear, descriptive, camelCase variable names.

Please provide only the complete, ready-to-use Apps Script code block.