In the script, how to abort following steps of an action?
Previously in drafts 4, I used “throw” to raise an exception to abort following steps of an action, and modify the draft content to show exception info.
But now, the throw code will cause modify draft content code to be invalid.
draft.content = “…” // show help info, this worked in drafts 4 but not in drafts 5!!!
It sounds to me like what you are looking for is the context object.
Great, but I still can’t modify the draft.conent property before called context.cancel() or context.fail().
Are you calling draft.update() after making your changes?
Yes I called. And it’s ok in drafts 4, but not work in drafts 5.
Is the condition valid ?
I think it is being modified, but for a cancel or fail the implicit reload of the draft into the editor won’t kick in, so you’ll need to do it manually.
See if this example helps.
draft.content = draft.content + "\n// Test Line //"
This works! Thanks. The editor has to be loaded manually.