Action

New Template Draft in Current Workspace

Posted by sylumer, Last update about 1 year ago - Unlisted

UPDATES

about 1 year ago

Fixed title

Creates a new draft in the current workspace based on a template defined for that workspace.

Steps

  • script

    const TEMPLATETAG = "workspace/" + app.currentWorkspace.name.toLowerCase();
    let arrTags = app.currentWorkspace.tagFilter.split(",");
    arrTags.splice(arrTags.indexOf("!" + TEMPLATETAG), 1);
    arrTags.push(TEMPLATETAG);
    let draftTemplate = Draft.query("", "all", arrTags,[], "modified", true, false)[0];
    let draftNew = Draft.create();
    draftNew.content = draftTemplate.content;
    draftTemplate.tags.map(strTag => draftNew.addTag(strTag));
    draftNew.removeTag(TEMPLATETAG);
    draftNew.update();
    editor.load(draftNew);
    editor.activate();

Options

  • After Success Default
    Notification Error
    Log Level Error
Items available in the Drafts Directory are uploaded by community members. Use appropriate caution reviewing downloaded items before use.