Simple (for somebody..) Script edit needed - process meeting

this following script is from an imported Action that:

  1. finds all "- [ ] " lines in the draft and sends each task to Things3 Inbox - ✓great
  2. collects - [ ] tasks together as list & appends them @ bottom of draft - ✓ great
  3. DELETES the - [ ] lines from the original location in the draft - :disappointed:

This is an awesome action for collecting action points from a document, but I’d like to leave the tasks in location as they are in the original draft.

Which lines need editing or deleting?

my script skills are null but I’m sure this is “Hello world” to someone…

thanks
S.

Action script code pasted:

// check to see if draft is blank

var content = editor.getText();
var check = content.length;
var taskList = “”;

if (content.length == 0) {
alert(“Draft is blank”);
context.cancel(“Draft was blank”);
}

// Call API for each line in a draft
// split draft and loop over lines
var lines = content.split("\n");

var thingsTask = Array();

for (var line of lines) {
if (line.startsWith("- [ ]")) {
task = line.replace("- [ ]", “”).trim();
temp = TJSTodo.create();
temp.title = task;
thingsTask.push(temp);
taskList += task + “\n”;
content = content.replace(line + “\n”, “”);
}
}

if (thingsTask.length) {
var container = TJSContainer.create(thingsTask);
var cb = CallbackURL.create();
cb.baseURL = container.url;
var success = cb.open();
if (success) {
console.log(“Tasks created in Things”);
content = content + “\n\nTasks collected:\n” + taskList;
editor.setText(content);
} else {
context.fail();
}
}

I don’t have Things but I believe you just need to delete (or comment out) the following line:

content = content.replace(line + “\n”, “”);

If you add two // to the front of the line it should turn grey in the editor (it is then a comment and won’t execute). Or just delete the line. Either way, that’s the line removing the task lines from the draft.

That worked perfectly by commenting that line out.

Thanks Bob. Appreciate the help.