Action

send lines to due, cal, things

Posted by franzi, Last update almost 2 years ago

iterates over each line in a list
sends items with #cal to fantastical
sends items with #due to due
and other lines to things

Steps

  • script

    
    const lines = draft.content.split('\n');
    const f = "x-fantastical3://x-callback-url/parse";
    const d = "due://x-callback-url/add";
    const t = "things:///add";
    lines.forEach((line) => {
        const lin = line.substring(0, line.indexOf('#'));
        var cb = CallbackURL.create();
        if (line === "") {
            return
        }
        if (line.includes('#due')) {
            cb.baseURL = d;
            cb.addParameter("title", lin);
        } else if (line.includes('#cal')) {
            cb.baseURL = f;
            cb.addParameter("sentence", lin);
        } else { 
            cb.baseURL = t;
            cb.addParameter("title", line);
        }
        var success = cb.open();
        if (success) {
            console.log("Event created");
    		script.complete()
        } else { // something went wrong or was cancelled
            console.log(cb.status);
            if (cb.status == "cancelled") {
                context.cancel();
            }
            else {
                context.fail();
    script.complete()
            }
        }
    })
    

Options

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