I've written a script within one of my google sheets that when a button is clicked it copies data from the active sheet and pastes it into another file. When logged in to any google account the script runs great but when anonymous users click the button nothing happens. According to the information regarding container-bound scripts, their permissions mirror the permissions of the container. I've insured that the container is shared for editing with anonymous users but the script still won't execute unless logged in.
What am I doing wrong? Code below.
function DataCapture() {
// Set Sheets
var source_sheet = SpreadsheetApp.getActiveSpreadsheet();
var target = SpreadsheetApp.openById("0AtYhRMASIGlFdGVQWFprMEpOOFRrUGYxTmNGd0dZLVE");
var target_sheet = target.getSheetByName('Data');
// Get target last row
var last_row = target_sheet.getLastRow();
// Set Ranges
var source_range = source_sheet.getRange("A2:P2");
var target_range = target_sheet.getRange("A"+(last_row+1)+":P"+(last_row+1));
var info_range = source_sheet.getRange("D7:E7");
var dollar_range = source_sheet.getRange("B7:B8");
var approver_range = source_sheet.getRange("D7:F7");
// Fetch values
var values = source_range.getValues();
// Save to spreadsheet
target_range.setValues(values);
// Clear the fields for the next entry
source_range.clearContent()
info_range.clearContent()
dollar_range.clearContent()
approver_range.clearContent()
}