crosslink to Craft and Omnifous

Posted by @FlohGro, Last update about 1 month ago

Cross-linking of a Craft Note and a Task in Omnifocus

  • this action will create a new Craft Document from the content of the current draft
  • the first line of the draft will be used as title of the Craft Document
  • after creating the Craft Document, the action will add a new taks to the inbox of Omnifocus. The title of the draft will be the name of the task and the task will contain a note with a link to the created craft document
  • after the task in omnifocus is created, the action will prepend a link to the omnifocus task into the previously created craft document.


  • to make this action work, you need to configure the spaceId.
  • 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-6c36499c8f3” after spaceId= in the link.
  • replace “unconfigured” with this id in the spaceID variable of the script (attention: only replace the unconfigured in line 5!).

if you find this useful you can Buy Me A Coffee


  • script

    // cross linked craft note and omnifocus task
    // 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"
    } else {
    let title = draft.displayTitle
    let encodedTitle = encodeURIComponent(title)
    let content = draft.content
    content = encodeURIComponent(content)
    var proceed = true;
    const craftCreateBaseURL = "craftdocs://x-callback-url/createdocument?"
    const craftCreateBlockBaseURL = "craftdocs://createblock?"
    const omnifocusAddBaseURL = "omnifocus:///add?"
    var cbCreateCraftNote = CallbackURL.create()
    cbCreateCraftNote.baseURL = craftCreateBaseURL
    cbCreateCraftNote.addParameter("spaceId", spaceID)
    cbCreateCraftNote.addParameter("title", title)
    cbCreateCraftNote.addParameter("content", content)
    cbCreateCraftNote.addParameter("folderId", "")
    cbCreateCraftNote.waitForResponse = true
    let craftCreateReturn =
    if (craftCreateReturn == true) {
        console.log("Craft note successfully created")
    } else {
        proceed = false
        console.log("Craft note result:" + cbCreateCraftNote.status + " " + cbCreateCraftNote.callbackResponse)
        if (cbCreateCraftNote.status == "cancelled") {
        } else {
    // craft note is created, now create the omnifocus task
    if (proceed) {
        // retrieve info from craftCreateResult
        let craftCreateResult = cbCreateCraftNote.callbackResponse
        var blockId = craftCreateResult.blockId
        var craftNoteLink =
        let taskNoteStr = "Craft Note: " + craftNoteLink
        var cbAddOmnifocusTask = CallbackURL.create()
        cbAddOmnifocusTask.baseURL = omnifocusAddBaseURL
        cbAddOmnifocusTask.addParameter("name", title)
        cbAddOmnifocusTask.addParameter("note", taskNoteStr)
        cbAddOmnifocusTask.addParameter("autosave", "true")
        cbAddOmnifocusTask.waitForResponse = true
        let omnifocusAddReturn =
        if (omnifocusAddReturn == true) {
            console.log("Omnifocus Task successfully created")
        } else {
            proceed = false
            console.log("Add Omnifocus task result:" + cbAddOmnifocusTask.status + " " + cbAddOmnifocusTask.callbackResponse)
            if (cbAddOmnifocusTask.status == "cancelled") {
            } else {
    // omnifocus task added now prepend the link to the previously created craft note
    if (proceed) {
        // retrieve info from craftCreateResult
        let omnifocusAddResult = cbAddOmnifocusTask.callbackResponse
        let showTaskUrl = omnifocusAddResult["result"]
        let openTaskStr = "> Task in Omnifocus: [" + title + "](" + showTaskUrl + ")"
        let encodedBlockContent = encodeURIComponent(openTaskStr)
        var cbCreateCraftBlock = CallbackURL.create()
        cbCreateCraftBlock.baseURL = craftCreateBlockBaseURL
        cbCreateCraftBlock.addParameter("spaceId", spaceID)
        cbCreateCraftBlock.addParameter("parentBlockId", blockId)
        cbCreateCraftBlock.addParameter("index", 0)
        cbCreateCraftBlock.addParameter("content", encodedBlockContent)
        cbCreateCraftBlock.waitForResponse = false


  • 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.