Action

Create Craft Note

Posted by @FlohGro, Last update 8 months ago

UPDATES

8 months ago

description update

show all updates...

8 months ago

description update

8 months ago

updated to use x-callback-url and fixed create document issues by encoding the content

8 months ago

updated to use x-callback-url scheme.

this action creates a craft note in a configurable space.
before first use please configure it to use your chosen.
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 of the script.

If you find this useful you can..
Buy Me A Coffee

Steps

  • script

    // created by @FlohGro
    
    // create Craft note
    
    // insert your preferred space ID 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"
    
    if(spaceID == "unconfigured"){
    
    let errorMsg = "the spaceID variable was not configured in the script"
    alert(errorMsg)
    context.fail(errorMsg)
    
    } else {
    let title = draft.displayTitle
    
    let content = draft.processTemplate("[[body]]")
    
    content = encodeURIComponent(content)
    
    const baseURL = "craftdocs://x-callback-url/createdocument?"
    
    var cb = CallbackURL.create()
    cb.baseURL = baseURL
    cb.addParameter("spaceId", spaceID)
    cb.addParameter("title", title)
    cb.addParameter("content", content)
    cb.addParameter("folderId", "")
    cb.waitForResponse = true
    
    let result = cb.open()
    
    if (result == true) {
        console.log("Craft note successfully created")
    } else {
        console.log("Craft note result:" + cb.status + " " + cb.callbackResponse)
        if (cb.status == "cancelled") {
            context.cancel()
        } else {
            context.fail()
        }
    }
    }

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.