Copy Script when copying an app

Hi guys,
what happens if I publish an app deployed with a Google Apps Script (Script editor) and I would like people to be able to copy the app?

Will they be able to use the script over their copied app?
If not, is there a workaround for this please?

Nope, you have to include that with your documentation, I imagine.

@Mark

Any way around this please?

Not that I know. Glide doesn’t touch, or even know about, your scripts.

1 Like

Cheers,
and I guess the “Copy sheet” option won’t help either?

Putting the triggers and permissions setting aside, can the script itself be migrated as is to the new Glider?

There are various options for publishing apps script projects as “Add-Ons”.
You can read more here

Another option could be to publish your script code via something like GitHub. You could use Clasp to create and maintain a local repository, and sync to GitHub for sharing. Anyone that has a copy of your Glide app could then apply your script by reversing the process, ie. clone your GitHub repo, and then import into a ScriptApp project using clasp. A bit cumbersome, but should work.

1 Like

Thanks Darren,

Does @anyone have an example of a Glide app with a similar practice?
Keen to see the documentation and the implementation of a GitHub/ Add-on based app?

I use Apps Script extensively in my GSheets projects, and have been using the Clasp/GitHub combination for versioning/source control for a few years now. It works well, and allows me to sleep a bit easier :slight_smile:

I’m quite new to Glide, and so I haven’t yet had the need to share any apps script code associated with a Glide project. But I see no reason why this approach wouldn’t work.

Thanks again,
When going with either Clasp/ GitHub, can (do I even need to?) set an “On Change” trigger on top of my sheet?

The answer to that I think depends on the purpose of the trigger.
If your app requires triggers in order to function correctly, then anyone who copies your app would need to install those triggers after copying the script code.

What you could do is include a README file as part of the repository with setup instructions.
Note that it is also possible to install triggers programatically, so if you wanted to get fancy you could include a “run once” function that installs any required triggers.

EDIT: Here is an example of a script that I sometimes use to install triggers. It gets called with the name of the function that I want called for each event, ie. on_form_submit, on_sheet_edit or on_sheet_change

function start_trigger(func) {
  var ss = SpreadsheetApp.getActive();
  switch (func) {
    case 'on_form_submit':
      ScriptApp.newTrigger(func)
      .forSpreadsheet(ss)
      .onFormSubmit()
      .create();
      break;
    case 'on_sheet_edit':
      ScriptApp.newTrigger(func)
      .forSpreadsheet(ss)
      .onEdit()
      .create();
      break;
    case 'on_sheet_change':
      ScriptApp.newTrigger(func)
      .forSpreadsheet(ss)
      .onChange()
      .create();
      break;
  }
}

Thanks!