Is there a way to grab a substring of Safe_Title in an action?

Is there a way to grab a substring of Safe_TItle in an action?

I’m using [[safe_title]].md in a ‘save to files’ action which I run over a bunch of drafts. Occasionally it barfs because the draft is a large paragraph without title and the resulting filename is too long.

On a related note, is it possible to filter drafts where an action has failed within Drafts itself rather than using the log?

There is no way to filter based on action log entries.

Also, no way to automatically truncate a tag value, but it’s pretty easily done in script. The below would give you a new [[short_safe_title]] tag to use in subsequent steps:

let maxLength = 30 // set to # of characters you want to limit to
// get the safe title value
let safe = drafts.processTemplate("[[safe_title]]")
if (safe.length > maxLength) {
    safe = safe.substring(0, maxLength)
draft.setTemplateTag("short_safe_title", safe)