Todoist Project Import: Extend to optionally select task attributes

The integration with Todoist is marvellous.

Particularly great is the ability to import a project into Drafts in Markdown format. Although Todoist has collaboration features, I’ve never really used it to collaborate in that sense. So when it has come to share details of projects I’m managing with Todoist, print to PDF has been the less than ideal way of sharing. Export to CSV is even worse. So this ability to import plain text is superb.

Based on this, would any Javascript wizards be able to take Greg’s base action (link below) and tweak it so that in addition to selecting the project to import, you could specify which task attribute, if any, you wanted to pull in too? I.e., date, label, priority.

This is what I was thinking of. Thanks in advance.

Import Project

  • Test task 1 (2018-0-13) @waiting p1

https://actions.getdrafts.com/a/1MH

Anyone know if the above would be feasible based upon the API?

Certainly at least partially.

As a quick example, I tweaked the above action to include priority (I stuck it in brackets for my own test).

The list of available fields and names is in the Todoist documentation referenced from the Drafts documentation for Todoist.

Due is in there so you can process that to pick the date/time format granularity you want. Completed might be useful to pick up, but I don’t see labels listed. I’d expect to see a list of IDs if they were available, but that screenshot suggests they might not be.

Hopefully that’s enough to point you in the right direction to modify the action to what you require.

1 Like

Cheers. Absolutely no clue as to what I’m doing with Javascript, but as there must be some planetary alignment going on, I managed to import this test project from Todoist.

AAA

  • [ ] Test 1 (due - 18 Jul 7:59 am)
  • [ ] Test 2 (due - 23 Jul 10:59 pm)

So a monumental achievement! Thanks for pointing me in theright direction.

1 Like

Evidently, just adding on “task.due.string.” Doesn’t cut it. Works fine if all tasks in project have due dates - fails to run if otherwise.

“Script Error: TypeError: undefined is not an object (evaluating ‘task.due.string’)
Line number: 56, Column 63”

I’ve peaked too early :grinning:

You can test for it’s presence:

if (task.due && task.due.string) {
    // add due to string here
}

I suspect they only send label_ids if labels are assigned as well. Comments would get more complicated, since they require an additional network request to fetch from Todoist.

Great. Thanks. I’ll try to work out where to put it.

Pulling in dates successfully will be mission accomplished. Not overly bothered about other attributes.

Sorry. Have tried fiddling but not got a clue where the above should sit in the script.

If anyone could add it in the right place in the below, it really would be appreciated.

https://actions.getdrafts.com/a/1Mk

This should do it…had to break out the construction of the string in the for loop:

for (let task of tasks) {
    let s = "- [ ] " + task.content;
    if (task.due && task.due.string) {
        s = s + " (due - " + task.due.string + ")";
    }
    content.push(s);
}
1 Like

Brilliant. Thanks ever so much for your help. Got it working now.