Create slip note

Posted by steinar/Ian Greig, Last update 4 months ago - Unlisted

Script by steinar Feb 2020 to create slip note from existing draft with title and ID


  • script

    const content = draft.content; // grabs the text of the current draft in the editor
    // One common option is to split the text by lines into an array
    let lines = content.split(“\n”);
    // removes the first line from array and assigns it to the title variable
    // turns the array back into a text string with line changes
    const title = lines.shift();const body = lines.join(“\n”);
    // Now create the ID
    const id = draft.processTemplate([[date|%Y%m%d%H%M]]);
    //Join the title with the id and the body of the text
    const newContent = title + “\n” + id + “\n” + body;
    // \n is the newline character
    // paste the new text (will replace the old draft)
    draft.content = newContent;
    draft.update(); // saves the changes


  • After Success Default , Tags: #slip, #note
    Notification Info
    Log Level Info
Items available in the Drafts Directory are uploaded by community members. Use appropriate caution reviewing downloaded items before use.