Updating the active draft

Something is eluding me here. Trying to have a script update the contents of a draft - the script ends with draft.update()

But I want the draft to stay in the editor.

General flow is:

Read draft.content into a variable
Set draft.content = “”
Rebuild and transform draft.content via some JavaScript code
Call draft.update()

Is there an editor function I need to invoke? Or reload the draft at the end?

It should automatically show the update.

Here’s an example that uppercases the entire draft content; I used an additional variable just to try and better match it to your flow, it isn’t strictly required for the processing done here.

https://actions.getdrafts.com/a/11L

Perhaps you could share your actual action? It may be that there is something missing. My gut would suggest that you are not setting the draft content to the updated value at the end, except that you are in fact explicitly blanking it in your example.

Also, if you navigate away from your draft and then back are you then seeing the draft update having taken effect?

Thanks - solved. Yours has same behavior. That’s when I realized that my default after action was to archive. Since the new action was set to follow default, when the action completed it archived the draft. Since the draft I was working with was flagged, it still showed on the flagged tab.

My bad. Thanks for making me realize it wasn’t the script!