Action

Create tasks and archive

Posted by Thomas Schoffelen, Last update over 1 year ago

Create tasks in Things for anything marked as a task (i.e. starting with - [ ]) in the document, then archive.

Steps

  • script

    const baseUrl = "things:///add";
    
    const lines = draft.content.split("\n");
    const notes = `From: ${draft.displayTitle}\n${draft.permalink}`
    
    const tasks = [];
    
    for (const line of lines) {
    	if (!line.includes("- [ ] ")) {
    		continue;
    	}
    
    	const title = line.replace("- [ ]", "").trim();
    	if (!title) {
    		continue;
    	}
    
    	tasks.push(title);
    }
    
    if(tasks.length){
    	const cb = CallbackURL.create();
    	cb.baseURL = baseUrl;
    	cb.addParameter("titles", tasks.join("\n"));
    	cb.addParameter("notes", notes);
    
    	const success = cb.open();
    	if (!success) {
    		if (cb.status == "cancelled") {
    			context.cancel();
    		} else {
    			context.fail();
    		}
    	}
    }

Options

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