Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

importing external javascript to google apps script [duplicate]

I am trying to use Trello from a Google Spreadsheet (Google Docs) and am not sure how to import/reference/link the javascript files required to use their library. My only other option is using their REST API directly (fine, but I'd rather use their js helper classes).

This is what Trello needs us to use:

 <script src="http://code.jquery.com/jquery-1.7.1.min.js"></script>  <script src="https://api.trello.com/1/client.js?key=substitutewithyourapplicationkey"</script> 

How would I import/include these in a Google Apps Script?

THANKS!!!

like image 788
dixkin Avatar asked Sep 05 '13 21:09

dixkin


People also ask

Is Google Apps Script just JavaScript?

Google Apps Script is a rapid application development platform that makes it fast and easy to create business applications that integrate with Google Workspace. You write code in modern JavaScript and have access to built-in libraries for favorite Google Workspace applications like Gmail, Calendar, Drive, and more.

How do I copy a Google script?

Just go to the script editor old spreadsheet and delete the script (or comment it out). Then open the script editor of the new spreadsheet and copy the script. Paste the script in the old spreadsheets script editor. Save it and you should be good to go.


2 Answers

Based on the answer here by Cameron Roberts, you can use the eval() function on the appscript UrlFetchApp function.

eval(UrlFetchApp.fetch('http://path.to/external/javascript.js').getContentText()); 
like image 68
owyongsk Avatar answered Sep 17 '22 20:09

owyongsk


you actually can . In the script project create another new file and simply just paste the JavaScript library copying from the source and save it then start referencing it from other file. It is that simple.

Or you can create another project with the .js lib and publish it and reference that script from the caller project, I wont do that unless that needs to be shared in multiple projects.

like image 37
kahmed Avatar answered Sep 19 '22 20:09

kahmed