Action

2Do Tasks

Posted by RosemaryOrchard, Last update almost 6 years ago

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

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();
    		}
    	}
    }

Options

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