Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to read the contents of a Google Apps Script from another Script

I'm looking for a way to read the contents of the script.gs files within a standalone Google Apps Script. I can't find a suitable getAs() Mime format in the Docslist.File service that doesn't fail. The context of this is that I want to use the html service/content service to be able to embed public GAS source samples in Google Sites and elsewhere. (in much the same way as embedding Gist Samples). Any ideas?

like image 723
bruce Avatar asked Nov 03 '12 15:11

bruce


People also ask

Is Google app script synchronous?

While Google Apps Script implements a subset of ECMAScript 5, there's nothing forcing it to be asynchronous. While it is true that JavaScript's major power is its asynchronous nature, the Google developers appear to have given that up in favor of a simpler, more straightforward API. UrlFetchApp methods are synchronous.

How can my Google Apps Script be run by others the sheet is shared with?

With the owner account, open the sheet, then script editor. Click on Publish and then Deploy as web app. For Execute the app as , choose User accessing the web app and for Who has access to the app , choose Anyone.

Is Google Apps Script just JavaScript?

Google Apps ScriptA cloud-based JavaScript platform that lets you integrate with and automate tasks across Google products.

How do you access a Google spreadsheet from the app script?

Enable the Google Sheets APIOpen the Apps Script project. Click Editor code. Next to Services, click Add a service add . Select Google Sheets API and click Add.


1 Answers

It is, in fact, possible. This gets Code.gs:

function myFunction() {
  throw ScriptApp.getResource("Code").getDataAsString();
}
like image 58
Corey G Avatar answered Nov 13 '22 15:11

Corey G