admin管理员组

文章数量:1355014

Is there a way to move some functions into separate files in google app script? currently my Code.gs looks like the following:

function onSubmit(e) {}

function readSpreadsheet(sheet) {}
function writeSpreadsheet(sheet, data) {}

function sendEmail() {}

function helperLogic1() {}
function helperLogic2() {}
function helperLogic3() {}
function helperLogic4() {}

So to make my code looks nicer ;p .. I want to move functions related to spreadsheet to spreadsheet.gs email to email.gs etc. So after moving them, how do I load it from the code.gs?

Thanks

Is there a way to move some functions into separate files in google app script? currently my Code.gs looks like the following:

function onSubmit(e) {}

function readSpreadsheet(sheet) {}
function writeSpreadsheet(sheet, data) {}

function sendEmail() {}

function helperLogic1() {}
function helperLogic2() {}
function helperLogic3() {}
function helperLogic4() {}

So to make my code looks nicer ;p .. I want to move functions related to spreadsheet to spreadsheet.gs email to email.gs etc. So after moving them, how do I load it from the code.gs?

Thanks

Share Improve this question edited Oct 30, 2013 at 22:15 Carl Manaster 40.4k17 gold badges108 silver badges157 bronze badges asked Oct 30, 2013 at 21:58 FajarmfFajarmf 2,2734 gold badges21 silver badges23 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 10

You can move any function to any script file inside the same project without restriction, it is indeed easier to read when you split the code in different categories when the code is long.

When you execute any of these function it behaves as if all of them where in the same .gs file. The project is the real container, not the file.

本文标签: javascriptGoogle app scriptmove some functions into separate filesStack Overflow