Hey all been creeping for awhile and starting to move most of my actions that launch shortcuts to run natively in drafts with some clean prompts. Just looking for some references to solve the following. I don’t mind figuring it out on my own using some regex and figuring out find and replace etc but I figured this can’t be a unique request.
So I have a draft for all my clients. In that draft I have a header “##### Activities” I also have actions for calling the client and emailing the client which grabs the phone number or my selected text to send as an email from the draft.
What I would like to do is add a step at the end of each action that would add “Phone Call - DATE - PROMPT(what the call was about) under that header.
So questions is would I do a regex on #### Activities until an empty line then add the log and then do a replace?
Any suggestions or better methods would be helpful. Fairly new to scripting but can look up something if I need too.
If activities is always the last section in the draft…
You could append your entry to the end for chronological ordering.
You could split() the draft content on the heading name and insert the new content between.
If it is not always the last section, I created some functions in TADpoLe for the editor object that allow you to append and prepend to Markdown headed sections that would probably simplify things for you;.
To use those functions, install and setup the ThoughtAsylum Action Group, then include the action TAD at the start of your own action.
RegEx could be a way to do it though if you prefer to roll your own solution from scratch.
Hi Randy, could you or @sylumer give some more detail to the example? I’m having the same problem you described but I’m not sure how to use the setText function to fix it.
oh, ok, got it. Turns out I was trying to grab the header via the “navigation markers” function and that wasn’t including the “#” that the TAD function was looking for. Here’s what I made: https://actions.getdrafts.com/a/1eS