Drafts Action Directory

Note repetition to things

Posted by @derekvan, derek , Last updated: 2018-04-27 03:02:57 UTC

This action is for creating a Things project that provides several reminders to review a specific note in another app. In my use case, I create a note in Day One, copy the link to the note in the clipboard, then share the notes with Drafts. Then I get reminders spaced at increasingly infrequent intervals, making sure that the content of the note stays in mind. The action, though, will grab any kind of link that is on the clipboard and use it for the notes field in each Things task.

The created project is added to an area called “notes”. You can review the script and change this if you like, you can also probably figure out how to change the spacing of the dates.

If you look at the script, you’ll see that I know very little about JavaScript. From playing robot turtles with my kids, I know that I need to do some kind of function to avoid all the repetitive code, but I needed to create this action before I had the time to properly learn how to code it. Thanks to Greg for making the Things documentation so clear.

Install

Steps

  • script

    var link = app.getClipboard();
    var d3 = Date.today().add(4).days();
    var rep3 = d3.toString('yyyy-MM-dd');
    var d4 = Date.today().add(6).days();
    var rep4 = d4.toString('yyyy-MM-dd');
    var d5 = Date.today().add(8).days();
    var rep5 = d5.toString('yyyy-MM-dd');
    var d6 = Date.today().add(11).days();
    var rep6 = d6.toString('yyyy-MM-dd');
    var d7 = Date.today().add(14).days();
    var rep7 = d7.toString('yyyy-MM-dd');
    var d8 = Date.today().add(22).days();
    var rep8 = d8.toString('yyyy-MM-dd');
    var d9 = Date.today().add(30).days();
    var rep9 = d9.toString('yyyy-MM-dd');
    var d10 = Date.today().add(60).days();
    var rep10 = d10.toString('yyyy-MM-dd');
    var d11 = Date.today().add(90).days();
    var rep11 = d11.toString('yyyy-MM-dd');
    var d12 = Date.today().add(120).days();
    var rep12 = d12.toString('yyyy-MM-dd');
    
    // create a Things Project
    var project = TJSProject.create();
    project.title = draft.processTemplate("[[title]]");
    project.area = "Notes";
    
    
    // add todos to the project
    var todo1 = TJSTodo.create();
    todo1.title = "review note";
    todo1.when = "today";
    todo1.notes = link;
    project.addTodo(todo1);
    
    var todo2 = TJSTodo.create();
    todo2.title = "review note";
    todo2.when = "tomorrow";
    todo2.notes = link;
    project.addTodo(todo2);
    
    var todo3 = TJSTodo.create();
    todo3.title = "review note";
    todo3.when = rep3;
    todo3.notes = link;
    project.addTodo(todo3);
    
    var todo4 = TJSTodo.create();
    todo4.title = "review note";
    todo4.when = rep4;
    todo4.notes = link;
    project.addTodo(todo4);
    
    var todo5 = TJSTodo.create();
    todo5.title = "review note";
    todo5.when = rep5;
    todo5.notes = link;
    project.addTodo(todo5);
    
    var todo6 = TJSTodo.create();
    todo6.title = "review note";
    todo6.when = rep6;
    todo6.notes = link;
    project.addTodo(todo6);
    
    var todo7 = TJSTodo.create();
    todo7.title = "review note";
    todo7.when = rep7;
    todo7.notes = link;
    project.addTodo(todo7);
    
    var todo8 = TJSTodo.create();
    todo8.title = "review note";
    todo8.when = rep8;
    todo8.notes = link;
    project.addTodo(todo8);
    
    var todo9 = TJSTodo.create();
    todo9.title = "review note";
    todo9.when = rep9;
    todo9.notes = link;
    project.addTodo(todo9);
    
    var todo10 = TJSTodo.create();
    todo10.title = "review note";
    todo10.when = rep10;
    todo10.notes = link;
    project.addTodo(todo10);
    
    var todo11 = TJSTodo.create();
    todo11.title = "review note";
    todo11.when = rep11;
    todo11.notes = link;
    project.addTodo(todo11);
    
    var todo12 = TJSTodo.create();
    todo12.title = "review note";
    todo12.when = rep12;
    todo12.notes = link;
    project.addTodo(todo12);
    
    
    // create a container to handle creation of Things URL
    var container = TJSContainer.create([project]);
    
    // Use CallbackURL object to open URL in Things.
    var cb = CallbackURL.create();
    cb.baseURL = container.url;
    var success = cb.open();
    if (success) {
    	console.log("Project created in Things");
    }
    else {
    	context.fail();
    }
Actions available in the Action Directory are uploaded by community members. Use appropriate caution reviewing downloaded actions before use.