Action

import Todoist Filter

Posted by FlohGro, Last update about 3 years ago

import a filter from a configurable array from todoist into a new draft

If you find this useful you can Buy Me A Coffee

Steps

  • script

    // created by @FlohGro
    // Todoist import todoist filter
    
    const filters = ["today | overdue", "today | tomorrow", "@waiting4", "no date"]
    
    var filter = ""
    
    let f = () => {
        // create Todoist object and load projects
        let todoist = Todoist.create();
        let tasks = todoist.getTasks({
            "filter": filter
        })
    
    
        if (todoist.lastError) {
            alert(todoist.lastError)
            return false
        }
    
    
        let content = [];
        content.push("# " + filter + "\n")
    
        for (let task of tasks) {
    
            let s = "- [ ] " + task.content;
            if (task.due && task.due.string) {
                s = s + " (due - " + task.due.string + ")";
            }
            content.push(s);
        }
        let d = Draft.create();
        d.content = content.join("\n");
        d.update();
        editor.load(d);
        return true;
    }
    
    
    var p = Prompt.create();
    p.title = "Select Filter";
    
    for (var fil of filters) {
        p.addButton(fil);
    }
    
    if (p.show()) {
       filter = p.buttonPressed
    
        if (!f()) {
            context.fail();
        }
    } else {
        context.cancel();
    }

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.