Skip to main content
Image

r/GoogleAppsScript


Is this a permissible onOpen operation? Is this a permissible onOpen operation?
Question

As background, my goal is to log a timestamp whenever a spreadsheet is opened.

That way, I can hibernate services running via an hourly time-based trigger if the spreadsheet has not been opened after 60 days.

I understand onOpen runs in AuthMode: Limited, but I'm not clear on whether that permits me to addDeveloperMetadata.

I'm getting the following error:

Could not update lastOpened metadata in onOpen: You do not have permission to perform that action.

Is this adding developer metadata via onOpen not achievable?

Is there a pattern for logging a "lastOpened" timestamp that can work in AuthMode Limited?

function stampLastOpened(spreadsheet) {
  var now = new Date().toISOString();
  var existing = spreadsheet
    .createDeveloperMetadataFinder()
    .withLocationType(
      SpreadsheetApp.DeveloperMetadataLocationType.SPREADSHEET
    )
    .withKey('lastOpened')
    .find();


  if (existing.length > 0) {
    existing[0].setValue(now);
  } else {
    spreadsheet.addDeveloperMetadata(
      'lastOpened',
      now,
      SpreadsheetApp.DeveloperMetadataVisibility.PROJECT
    );
  }
}

function onOpen() {
  var ss = SpreadsheetApp;
  try {
    stampLastOpened(ss.getActiveSpreadsheet());
  } catch (e) {
    Logger.log('Could not update lastOpened metadata in onOpen: ' + e.message);
  }
}

The apps you know go further with Copilot.
media poster


what are you actually building with google apps script that people pay for? what are you actually building with google apps script that people pay for?
Question

I’ve been playing with Google Apps Script + Sheets for a while and I feel like I’m just making random automations that look cool but probably useless in real life

trying to get out of that loop

if you’ve built something with Apps Script that:

  • a business actually used

  • or better, paid for

what was it?

I’m mainly looking for stuff like:

  • simple dashboards (finance / sales / reporting)

  • automations inside Google Workspace

  • anything repeatable I can turn into a small “product”

not looking for tutorials or docs
more like real examples, even small ones

if you’ve got:

  • github repos

  • templates

  • scripts

  • ideas that can be reused

please share

also curious how you found people to sell it to
right now I have no clue where those people even are

just trying to make this practical instead of building in a vacuum


Include instructions being ignored. Include instructions being ignored.
Question

Hi all,

Not sure what's going wrong, but here goes.

I'm making a wizard for a button function in google sheets. In my html file, I try to include wizard.js and wizard.css

they never end up working properly. i have confirmed (with console outputs) that the <script> and <style> tags that hold the <include?!=> are being ignored completely.

debug lines before and after the <script> tag fire. debug lines inside the <script> tag fail.

separate console outputs in their own <script> tag still fire, so it's not the case that all <scripts> are being stripped. templating is working as intended.

is there a wierd quirk with app scripts that I should know about?

Edit to add: I originally had a project that was working. After some edits it suddenly stopped accepting the includes. I restarted the entire process when I first hit this issue, and am now running into it again.