Phrased another way, is there a way to:
- Create a new Google Spreadsheet (from the Google Drive API)
- And then create a Google Apps Script associated with that Google Spreadsheet programmatically
- And then programmatically activate the "On Edit" and "On Form Submit Triggers" to call various methods in the script? (this is the part I cannot figure out)
-OR- (as @JacobFlatter suggested)
- Manually create a spreadsheet with the desired script
- Use the Google Drive API to programmatically copy the spreadsheet (which copies with script with it as well)
- Somehow programmatically activate the "On Edit" and "On Form Submit Triggers" (which DO NOT copy over from copying the spreadsheet, this is the part I cannot figure out)
Possible path to follow:
Create a container bound script with an onOpen() trigger within a spreadsheet.
Copy the existing Spreadsheet (which will copy the script as well) programmatically.
Open the new Spreadsheet programmatically (unsure if this will initiate the trigger described above).
This assumes a few things, but seems like it is worth investigating. I'm curious if this works. Good Luck.
Unfortunately, no. You cannot do meta programming with Apps Script.
Based on the answer to this question, I wrote a simple function to try meta programming
function meta(){
var mime = 'application/vnd.google-apps.script';
DocsList.createFile('MetaScript','function test(){}', mime);
}
It throws up an error saying Invalid mime type