Issue with drafts action

I am using this draft action to try and parse my meeting notes into omnifocus tasks.

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

What I was hoping to do was use " - [ ] " as the marker for tasks as it is the most obvious it, being the checklist mark. However when ever I run the action all the omnifocus tasks it creates are titled undefined. Is there any reason why this would be?

Many thanks in advance for any help

Apologies for the quick hack (I’m getting my eldest ready for school at the same time), but the issue I think will be that the square brackets have a special meaning in regular expressions; which the script step is using for the removal of the line entry.

Simplifying the removeTaskPrefix function and effectively hard coding (told you it was a quick hack) the prefix I think will work and is shown below - replace the removeTaskPrefix function in your script action. Not nice, but hopefully it is a quick fix. I can’t test it myself as I’m not an Omnifocus user, but it’s my best guess right now.

// Scan for Task Prefix

var taskPrefix = "-[ ] ";

// Function for removing the task prefix
function removeTaskPrefix(s) {
  return s.replace(/^-\[ \] /g,"");
}

Let me know if it works, or if the error changes in any way.

2 Likes

It works!!

Thank you very much

When I tried the first few times it would run but it appeared to not identify the lines where I had put the - [ ]. Turns out there was a space missing before the first [ causing it to not see the markdown notation as the identifier.

Thanks again for your help. Hope you got your oldest to school on time even whilst writing code for me :joy:

1 Like