Action

add Daily Note Template to Todays Craft Note

Posted by @FlohGro, Last update about 1 month ago

Add Daily Note Template to Todays Craft Note

Created by FlohGro

  • this action is designed to add a Template for a Daily Note to the todays note in Craft
  • you can create and modify the template in drafts and run the action to add the BODY of the template to the Daily Note in Craft
  • since the URL Scheme of Craft currently can’t directly add something to a daily note this action needs a shortcut to be installed on your device(s) - read more about that in the “REQUIREMENTS” section
  • before you can use this action you have to configure it with your daily note template (and set this up if you don’t have one)

REQUIREMENTS

  • as mentioned this action needs a shortcut to be installed on your device(s) to work properly
  • the shortcut just adds the given /text) content to the todays note - so nothing fancy
  • you can download the shortcut here

CONFIGURATION

To configure this action you need to do two things:
- setup a template draft
- insert the UUID of the template draft into this action

Setup of a Template Draft

You can use any draft as your daily note template. It is just important to know that the action will just use the body of the template draft and ignore the first line (title). Therefore you can use a header for the draft like “# Craft Daily Note Template” and you won’t see the header in every Daily Note in Craft.

You can also insert Links to other Craft Notes in the Template and they will be directly linked in Craft - this is really useful if you e.g. have a “Gratitude note” and also want to note things you are grateful for in your daily notes - then the daily note will be linked to your “normal” Gratitude Note. To insert the links to other documents, just copy their markdown deeplink into the template.

If you already have a Template for your daily note in Craft you can simply export it as Markdown to Drafts. Remember to set a header for that draft afterwards.

See the example below:

# Craft Daily Note Template
## Today Bible Reading

- notes

## [Gratitude](craftdocs://open?blockId=<<blockId>>&spaceId=<<spaceId>>)

- notes

## Daily Notes

- notes

insert the UUID into the Action

  • to tell the action which Draft is your template, simply copy the UUID of the template Draft
  • edit the action and navigate into the first step which is a “Define Template Tag” step.
  • replace the “UUID_OF_THE_TEMPLATE_DRAFT” with the UUID you just copied from the template draft

Run the Action

  • if you completed the configuration you can run the action with any draft open in the editor
  • it will open the shortcuts app and the template will be appended to your daily note

Known Issues

  • if you create your daily note on one of your devices (e.g. your iPhone) and Craft did not sync on another device (e.g. your iPad) and you run the action again, you will see two daily notes next to each other. This is a known issue at Craft → don’t run the action on two different devices on the same day (which does not make sense anyways)

If you find this useful you can Buy Me A Coffee

Steps

  • defineTemplateTag

    name
    TemplateDraftUUID
    template
    UUID_OF_THE_TEMPLATE_DRAFT
  • script

    // create a wrapper function that returns a boolean
    let f = () => {
    	let uuidToUse = draft.processTemplate("[[TemplateDraftUUID]]");
    	if(uuidToUse == "UUID_OF_THE_TEMPLATE_DRAFT"){
    	let errorStr = "the action was not configured with a template draft. please read the docs and add a valid UUID to the first step in this action"
    	alert(errorStr);
    	return false;
    	}
    
    
    
    	let template = Draft.find(uuidToUse);
    	let content = template.processTemplate("[[body]]");
    	draft.setTemplateTag("templateBody",content);
    	return true;
    }
    
    // call the wrapper, use result to control cancellation
    if (!f()) {
        context.fail();
    }
    
  • runShortcut

    shortcutName
    Add to Todays Note
    waitForResponse
    false

Options

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