# Copy Script when copying an app

**URL:** <https://community.glideapps.com/t/copy-script-when-copying-an-app/17750>\
**Category:** Ask for Help\
**Created:** [October 30, 2020, 4:02am UTC](https://community.glideapps.com/t/copy-script-when-copying-an-app/17750 "2020-10-30T04:02:30Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ryan](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/ryan/32/15941_2.png) [@Ryan](https://community.glideapps.com/u/Ryan)\
**Post date:** [October 30, 2020, 4:02am UTC](https://community.glideapps.com/t/copy-script-when-copying-an-app/17750/1 "2020-10-30T04:02:30Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![ThinhDinh](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/thinhdinh/32/49_2.png) [@ThinhDinh](https://community.glideapps.com/u/ThinhDinh)\
**Post date:** [October 30, 2020, 4:21am UTC](https://community.glideapps.com/t/copy-script-when-copying-an-app/17750/2 "2020-10-30T04:21:29Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Ryan](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/ryan/32/15941_2.png) [@Ryan](https://community.glideapps.com/u/Ryan)\
**Post date:** [November 1, 2020, 10:00pm UTC](https://community.glideapps.com/t/copy-script-when-copying-an-app/17750/3 "2020-11-01T22:00:47Z")

</div>

@Mark

Any way around this please?

---

<div class="post-metadata">

**Author:** ![Mark](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/mark/32/125_2.png) [@Mark](https://community.glideapps.com/u/Mark)\
**Post date:** [November 2, 2020, 12:15am UTC](https://community.glideapps.com/t/copy-script-when-copying-an-app/17750/4 "2020-11-02T00:15:00Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Ryan](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/ryan/32/15941_2.png) [@Ryan](https://community.glideapps.com/u/Ryan)\
**Post date:** [November 2, 2020, 3:59am UTC](https://community.glideapps.com/t/copy-script-when-copying-an-app/17750/5 "2020-11-02T03:59:37Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![Darren\_Murphy](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/darren_murphy/32/47326_2.png) [@Darren\_Murphy](https://community.glideapps.com/u/Darren_Murphy)\
**Post date:** [November 3, 2020, 4:08am UTC](https://community.glideapps.com/t/copy-script-when-copying-an-app/17750/6 "2020-11-03T04:08:50Z")

</div>

There are various options for publishing apps script projects as “Add-Ons”.  
You can read more [here](https://developers.google.com/gsuite/add-ons/how-tos/publish-add-on-overview)

Another option could be to publish your script code via something like GitHub. You could use [Clasp](https://codelabs.developers.google.com/codelabs/clasp#0) 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.

---

<div class="post-metadata">

**Author:** ![Ryan](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/ryan/32/15941_2.png) [@Ryan](https://community.glideapps.com/u/Ryan)\
**Post date:** [November 4, 2020, 4:34am UTC](https://community.glideapps.com/t/copy-script-when-copying-an-app/17750/7 "2020-11-04T04:34:01Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![Darren\_Murphy](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/darren_murphy/32/47326_2.png) [@Darren\_Murphy](https://community.glideapps.com/u/Darren_Murphy)\
**Post date:** [November 4, 2020, 4:40am UTC](https://community.glideapps.com/t/copy-script-when-copying-an-app/17750/8 "2020-11-04T04:40:55Z")

</div>

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 🙂

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.

---

<div class="post-metadata">

**Author:** ![Ryan](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/ryan/32/15941_2.png) [@Ryan](https://community.glideapps.com/u/Ryan)\
**Post date:** [November 9, 2020, 5:22am UTC](https://community.glideapps.com/t/copy-script-when-copying-an-app/17750/9 "2020-11-09T05:22:21Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Darren\_Murphy](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/darren_murphy/32/47326_2.png) [@Darren\_Murphy](https://community.glideapps.com/u/Darren_Murphy)\
**Post date:** [November 9, 2020, 5:48am UTC](https://community.glideapps.com/t/copy-script-when-copying-an-app/17750/10 "2020-11-09T05:48:54Z")

</div>

> [@Ryan](#):
>
> 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;
  }
}

```

---

<div class="post-metadata">

**Author:** ![Ryan](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/ryan/32/15941_2.png) [@Ryan](https://community.glideapps.com/u/Ryan)\
**Post date:** [November 10, 2020, 3:53am UTC](https://community.glideapps.com/t/copy-script-when-copying-an-app/17750/11 "2020-11-10T03:53:56Z")

</div>

Thanks!
