javascript - Defining constants in Google Apps Script that can be used across multiple projects. -


I have around 15-20 Google Apps Script projects that use the same list of all constants.

Everything that I have done is defined in the project above all the constants on the first script file, and then copied and pasted the block of code at the same place in each project. So if I make changes in one, then I am copying and pasting that item in the rest of the thing, it becomes time consuming. Is it a better way to do this? Is it using? Does anyone use libraries to define constants in projects?

Using a library for a shared compiler is the most effective way to keep continuous objects between Google Apps scripts Some warnings to share:

  • All scripts using ConstLib will need to do this with "development mode", otherwise you will have to manually update each of them Needed (risk: save a buggy version of the castlib And all your scripts will break immediately.) screenshot
  • Properties of the static library Therefore, it will be necessary to refer to using the library name, for example

      var log = SpreadsheetApp.openById (ConstLib.auditLogId);   

    In your current script, you can find the existing constants to be converted to blocks in the context of your ConstLib, so you will not need to touch the rest of the code. E.g.

      var auditLogId = ConstLib.auditLogId; . . . Var log = spreadsheet app.openbiid (audit logim);     

    example

    ConstLib

     < Code> Various rose = "red", violet = "blue";   

    Use the CastBab

      function myFunction () {Logger.log (ConstLib. Roses); Logger.log (ConstLib.violets); } [14-10-09-14: 51: 47: 258 EDT] Red [14-B] [14-10-09-14: 51: 47: 258 EDT]   

    Logging Output 10-09 14: 51: 47: 25 9 EDT] Blue

Comments

Popular posts from this blog

php - PDO bindParam() fatal error -

logging - How can I log both the Request.InputStream and Response.OutputStream traffic in my ASP.NET MVC3 Application for specific Actions? -

java - Why my included JSP file won't get processed correctly? -