Sharing Apps Script & Setup Instructions

How to Share the Apps Script

Method 1: Share the Google Sheet (Easiest)

The Apps Script is embedded in the Google Sheet, so sharing the sheet shares the script.

  1. In your Google Sheet:

    • Click Share (top right)
    • Add the person’s email
    • Give them Editor access (needed to run scripts)
    • Click Send
  2. They will:

    • Receive access to the sheet
    • Have access to the script automatically
    • Need to set up their own trigger (see below)

Method 2: Export/Import Script (If Needed)

If you want to share just the script code:

  1. Export:

    • Extensions → Apps Script
    • File → Download → .gs file
    • Share the downloaded file
  2. Import:

    • They create a new Google Sheet
    • Extensions → Apps Script
    • File → New → Script file
    • Paste the code
    • Save

Setup Steps in the Google Sheet

Step 1: Verify Sheet Names

Make sure these sheets exist with exact names:

  • Wholesale Customers Data - From Snowflake (source)
  • Report - All Wholesale Customers (destination)

To check:

  • Look at the sheet tabs at the bottom
  • Names must match exactly (case-sensitive, including spaces)

Step 2: Set Up Headers in Report Sheet

  1. Go to “Report - All Wholesale Customers” sheet
  2. Row 1 should have headers:
    • Copy headers from “Wholesale Customers Data - From Snowflake” sheet
    • Or manually add: Customer ID, Email, Full Name, Phone, Company Name, etc.
  3. Headers should be static text (not formulas)

Step 3: Verify Script is Installed

  1. Extensions → Apps Script
  2. Verify the code is there:
    • Should see copyWholesaleData() function
    • Should see setupDailyTrigger() function
    • Should see manualCopy() function

Step 4: Set Up Daily Trigger

Option A: Using the Setup Function (Easiest)

  1. In Apps Script editor:
    • Select setupDailyTrigger from function dropdown
    • Click Run (▶️)
    • Authorize permissions when prompted
    • You’ll see: “Daily trigger set up! Data will copy automatically at 6 AM.”

Option B: Manual Trigger Setup

  1. In Apps Script editor:
    • Click Triggers icon (⏰) in left sidebar
    • Click + Add Trigger (bottom right)
    • Configure:
      • Function to run: copyWholesaleData
      • Event source: Time-driven
      • Type: Day timer
      • Time: 6am to 7am (or your preferred time)
    • Click Save
    • Authorize permissions

Step 5: Test the Script

  1. Run manually to test:

    • In Apps Script: Select manualCopy function
    • Click Run (▶️)
    • Authorize if prompted
  2. Check the result:

    • Go to “Report - All Wholesale Customers” sheet
    • Data should appear starting from row 2
    • Headers in row 1 should remain unchanged

Step 6: Add Filters (Optional)

Once data is copied:

  1. Select row 1 (headers)
  2. Data → Create a filter
  3. Filters will work normally (no formula conflicts!)

For the Person Receiving the Script

First-Time Setup Checklist

  • Access the Google Sheet (shared with them)
  • Verify sheet names match:
    • Wholesale Customers Data - From Snowflake exists
    • Report - All Wholesale Customers exists
  • Check headers in Report sheet:
    • Row 1 has column headers (static text)
  • Open Apps Script:
    • Extensions → Apps Script
    • Verify code is present
  • Set up trigger:
    • Run setupDailyTrigger() function
    • OR manually add trigger via Triggers sidebar
  • Test the script:
    • Run manualCopy() function
    • Verify data copies correctly
  • Verify automatic run:
    • Check trigger is set (Triggers sidebar)
    • Wait for scheduled time or test manually

Sharing Checklist

Before Sharing

  • Script code is saved in Apps Script
  • Sheet names are correct
  • Headers are set up in Report sheet
  • Script has been tested and works

When Sharing

  • Share Google Sheet with Editor access
  • Provide these instructions to the recipient
  • Let them know they need to:
    • Set up their own trigger (one-time)
    • Authorize permissions (one-time)

Permissions & Authorization

What Permissions Are Needed

The script needs:

  • ✅ Read access to source sheet
  • ✅ Write access to destination sheet
  • ✅ Access to Google Sheets API

Authorization Process

  1. First time running script:

    • Google will prompt for authorization
    • Click “Review permissions”
    • Choose your account
    • Click “Advanced” → “Go to [Project Name] (unsafe)”
    • Click “Allow”
  2. Why “unsafe”:

    • Google shows this for unverified apps
    • It’s safe if you trust the code
    • Your script is private to your organization

Troubleshooting for Recipients

”Sheet not found” Error

Problem: Script can’t find source or destination sheet

Solution:

  • Verify sheet names match exactly
  • Check for typos or extra spaces
  • Sheet names are case-sensitive

”Permission denied” Error

Problem: Script doesn’t have access

Solution:

  • Ensure they have Editor access to the sheet
  • Re-authorize permissions
  • Check trigger is set up correctly

Trigger Not Running

Problem: Daily copy isn’t happening

Solution:

  • Check Triggers sidebar (⏰ icon)
  • Verify trigger exists and is enabled
  • Check execution log for errors
  • Test manually with manualCopy()

Data Not Copying

Problem: Script runs but no data appears

Solution:

  • Check source sheet has data
  • Verify source sheet name is correct
  • Check execution log for errors
  • Ensure destination sheet has headers in row 1

Quick Reference: Setup Steps

For You (Initial Setup)

  1. ✅ Create script in Apps Script
  2. ✅ Save script
  3. ✅ Set up daily trigger
  4. ✅ Test with manualCopy()
  5. ✅ Share sheet with Editor access

For Recipient (First Time)

  1. ✅ Open shared Google Sheet
  2. ✅ Verify sheet names exist
  3. ✅ Check headers in Report sheet
  4. ✅ Open Apps Script (Extensions → Apps Script)
  5. ✅ Run setupDailyTrigger() function
  6. ✅ Test with manualCopy()
  7. ✅ Verify trigger is set (Triggers sidebar)

Alternative: Share Script Code Only

If you want to share just the code (not the sheet):

Export Script

  1. Extensions → Apps Script
  2. File → Download → .gs file
  3. Share the .gs file

Recipient Imports

  1. Create new Google Sheet
  2. Extensions → Apps Script
  3. Delete default code
  4. Paste your script code
  5. Save
  6. Follow setup steps above

Summary

To share:

  • Share the Google Sheet with Editor access
  • Script is automatically included

Recipient needs to:

  • Set up their own trigger (one-time)
  • Authorize permissions (one-time)
  • Test the script

No deployment needed - just share the sheet and set up triggers!