Multiple Dropbox accounts: Loading a specific TaskPaper document, in Dropbox, via javaScript in Drafts


#1

:wave:t3:all

Anyone know how to specify which Dropbox account via scripting? I’ve found this in the docs var db = Dropbox.create(); but I get an error when adding the name of the account in the params var db = Dropbox.create('Personal');

I’m a total newb with scripting from within Drafts and my JavaScript is rusty, at best. Thanks for any advice. Full script is below (in case my error is elsewhere).

//taskpaper file in dropbox

var TPpath = 'path/to/file.taskpaper';
var db = Dropbox.create('Personal');
var content db.read(TPpath);
editor.setText(content);

#2

You are on the right track. The Dropbox create call looks ok, you are missing an = in line three. Try:

var TPpath = 'path/to/file.taskpaper';
var db = Dropbox.create('Personal');
var content = db.read(TPpath);
editor.setText(content);

Note that if you are getting error, check the action log (history button at top of action list panel). If it’s a script syntax error you will get line number of the problem.


#3

Awesome, thanks for the code review and the info on the action log. Sorry for the silly error. Appreciate your time and attention. I’m a big TaskPaper on Mac user, and I’m exploring if Drafts can be my TaskPaper client on iOS (In addition to everything else it does for me).

Have a great weekend, and thanks again.