Drafts Action Directory

2Do Tasks

Posted by RosemaryOrchard, Last updated: 2018-07-04 14:02:52 UTC

This action takes the each line of the current Draft and adds them to 2do as a separate note.

Install

Steps

  • script

    // See online documentation for examples
    // http://getdrafts.com/scripting
    const baseURL = "twodo://x-callback-url/add";
    
    var tasks = draft.content.split("\n");
    for (var task of tasks) {
    	// create and configure callback object
    	var cb = CallbackURL.create();
    	cb.baseURL = baseURL;
    	cb.addParameter("task", task);
    	// open and wait for result
    	var success = cb.open();
    	if (success) {
    		console.log("Task created");
    	}
    	else { // something went wrong or was cancelled
    	  	console.log(cb.status);
    	  	if (cb.status == "cancel") {
    			context.cancel();
    		}
    		else {
    			context.fail();
    		}
    	}
    }

Comments

Actions available in the Action Directory are uploaded by community members. Use appropriate caution reviewing downloaded actions before use.