Possible to a file a draft under a specific heading in document

I’ve looked around the forums for a bit, so I’m sorry if this has been answered.

Is it possible to automatically file a draft, under a specified heading?

Hopefully I can illustrate my goal with this example:

Let’s say I’ve create a markdown document on Dropbox called “Employee Tasks” that looks like this:

# Tasks

## Tyler
- [ ] Talk to Darth Vader

## Ryan
- [ ] Talk to Luke Skywalker

I’ve created (2) actions called:

  • Task for Tyler
  • Task for Ryan

I make a task called “Run away from Boba Fett” and click the action for Tyler.

So now, rather than appending or prepending the file. It adds it under Tyler like this.

# Tasks

## Tyler
- [ ] Run away from Boba Fett
- [ ] Talk to Darth Vader

## Ryan
- [ ] Talk to Luke Skywalker

Is this something that’s possible?

Yes. You would need to script a split of the file by headings, loop through them to find the split with the right heading, append your entry to that split, recombine all of the splits, and then overwrite the file with the combination.