Drafts Action Directory

New Bear Note to Things

Posted by @craigmcclellan, Last update 4 months ago - Unlisted

Create a new note in Bear, then send the link to that note to Things as a task.

Install

Steps

  • script

    // New Bear Note and Things Task
    
    // Send draft title and body to Bear as a note via x-callback
    const bearURL = "bear://x-callback-url/create";
    var title = draft.processTemplate("[[safe_title]]");
    var note = draft.processTemplate("[[body]]");
    
    var cb = CallbackURL.create();
    cb.baseURL = bearURL;
    cb.addParameter("title", title);
    cb.addParameter("text", note);
    
    var success = cb.open();
    if (success) {
    	var noteID = cb.callbackResponse["identifier"];
    }
    else {
    	context.fail();
    }
    
    // Use x-success parameter to create link to newly created note
    var noteURL = "bear://x-callback-url/open-note?id=" + noteID;
    
    // Create task in Things with title as task name and link to Bear note as note
    var todo = TJSTodo.create();
    todo.title = title;
    todo.notes = noteURL;
    
    var container = TJSContainer.create([todo]);
    
    var tcb = CallbackURL.create();
    tcb.baseURL = container.url;
    var success = tcb.open();
    
    if (success) {
    	console.log("Task added to Things");
    }
    else {
    	context.fail();
    }

Options

  • After Success Default
    Notification Info
    Log Level Info
Actions available in the Action Directory are uploaded by community members. Use appropriate caution reviewing downloaded actions before use.