Action

Append to Craft Note

Posted by FlohGro, Last update 4 days ago

UPDATES

4 days ago

Action now appends the whole draft, not just the body

this action appends the content of the current draft to a configurable document in a space.
before first use please configure it to use your chosen document.
You can get it by copying the deeplink of a document (not a block inside the document) in a space. Paste the link into a new draft and extract the combination like “2159f404-e3ed-4d8a-fbe1-6c361399c8f3” after spaceId= in the link. replace “unconfigured” with this id in the spaceID variable of the script. Do the same for the (parent)blockId.

Steps

  • script

    // created by @FlohGro
    
    // append to Craft note
    
    // insert your preferred space ID and blockID for a document here. You can get it by copying the deepplink of a document in this space. Paste the link into a new draft and extract the combination like "2159f404-e3ed-4d8a-fbe1-6c361399c8f3" after spaceId= in the link. replace "unconfigured" with this id in the spaceID variable.
    
    
    const spaceID = "unconfigured"
    const parentBlockID = "unconfigured"
    
    if(spaceID == "unconfigured" || parentBlockID == "unconfigured"){
    
    let errorMsg = "the spaceID & / or the parentBlockID variable was not configured in the script"
    alert(errorMsg)
    context.fail(errorMsg)
    
    } else {
    let content = draft.processTemplate("[[draft]]")
    
    const baseURL = "craftdocs://createblock?"
    
    // index needed as high number to append the content at the end of a craft document
    const index = 100000
    var cb = CallbackURL.create()
    cb.baseURL = baseURL
    cb.addParameter("spaceId",spaceID)
    cb.addParameter("parentBlockId",parentBlockID)
    cb.addParameter("index",index)
    cb.addParameter("content",content)
    //cb.addParameter("folderId","")
    cb.waitForResponse = false
    
    //let result = cb.open
    cb.open()
    }

Options

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