Thursday, April 27, 2023

How I automated my daily log using Power Automate and OneNote

Screenshot of Power Automate flow

Keeping a daily log is a great way to stay organized and on top of your tasks. I used to create a new page in my OneNote notebook every day, but it was a manual process that took time and effort. 
That's why I decided to create a Power Automate flow that would automatically add a new page to my OneNote notebook every day at 7am.

Here's what I wanted my daily log to include:
  • The date in the title
  • Section for Highlight (priority task)
  • Section on Yesterday (What I was working on yesterday)
  • Section on Today (What I will work on today)
  • Section on Start of Day checklist (with a number of checkbox fields)
  • Section on Working area
  • Section on End of Day checklist (with a number of checkbox fields)
Screenshot of OneNote daily log

I encountered three problems when creating this flow, but I was able to overcome them.

Problem #1: Getting the flow to trigger on only Monday to Friday.

The controls in Power Automate give you the option to set a frequency for your flow, and my initial idea was to set it to "once per day". However, this would include weekends, which I didn't want. After thinking for a bit, I figured out that I could set the frequency to "Weeks interval 1" and then choose which days of the week to include. It wasn't very intuitive, but I was able to figure it out.

Screenshot of the Reccurence block

Problem #2: Adding the date to the title field.

In the OneNote "Create a page in section" block, there wasn't a setting to enter a title. It only had a text entry for any template text you want on the page. After some trial and error, I discovered that I could switch the text entry to HTML and enter a full HTML page into the editor. Using the <title> tag within <head>, I was able to automate the title. I then added the formatDateTime function, which allowed me to get the title to be today's date in a long format.

Screenshot of HTML title

Problem #3: Adding checkboxes to the Start of Day and End of Day sections.

I really wanted to have checkboxes to check off my day start and end routines, but I couldn't figure out how to add checkboxes into the HTML. After some Googling, I found the data-tag="to-do" attribute, which gave me exactly what I was looking for. I added this attribute to the <p> tags in the Start of Day and End of Day sections, and it created checkboxes in OneNote.

Screenshot of HTML data tag

Overall, this flow has saved me a lot of time and effort, and it's helped me stay organized and focused on my tasks. If you're interested in creating a similar flow, I hope my experience can help you overcome any challenges you might encounter.