Automated notebook Templates for OneNote

Titel OneNote Template Blogpost

How can I create a full Template for a full OneNote notebook? This question is to me a few days ago on twitter, in my time lime "" flushed.

Für die Desktopversion kann man sich sehr einfach eine Datei mit der Endung .onepkg erstellen. Klick man auf diese Datei wird ein neues Notebook erstellt. Allerdings funktioniert das nur in der Windows Desktop Anwendung. Also habe ich mir mal angeschaut, was über Power Automate denn möglich ist.

Power Automate OneNote Connector...

Let's look at the Connector and the associated Trigger for OneNote in Power Automate:

As we can see, there are currently only a Connector for the OneNote Business Version. I.e., all the triggers are for the Business Version, and do not work for OneNote’s which are in the personal OneDrive.

What are the triggers are available:

  • Create a section in a notebook
  • Sections of a notebook to retrieve/read
  • All notebooks retrieve/read
  • A page in the create Quick notes
  • A page in an existing section to create a
  • A page erase (still in Preview)
  • Pages from a specific section of retrieving/reading
  • The page content to retrieve/read
  • Be teninhalt update (still in Preview)

What is striking at first glance, is that there is no way via Power Automate to create a new Notzibuch. Before doing so manually, a note must be created on the register in order to fill it then use sections and pages.

Anyone familiar with Powershell, you can create this way a script-driven automated process. But I would like to keep track of the whole now with Power Automate more and with this Board means a solution to build.

A possible process...

So if we have a new OneNote notebook in need of, for example, for a team book, we will create a new book in a matching channel in Teams. In the next step, we need to give the user an opportunity to the new notebook on the Basis of a Template automate customize.

Therefore, I've devised the following process. Having a notebook has been created, select the Creator of a Forms a Template, and thus start the process.

The Forms...

We create a new form with two input possibilities. First of all, we, the practitioner asked at the end, which Template should be used. The deposited using a select query as a drop down. Examples can be Templates for marketing campaigns, projects, or Onboardings. The second question is a free text input. Here is the Application you must enter the exact name of the newly created OneNote notebook.

This Forms is now our Trigger/trigger for the Power Automate process.

The Power Automate Process...

Since our starting point is a Forms, starts our process is sent a new answer. So, we need the following first two steps in the process.

  1. the Trigger when a new response is received
  2. the response of the details still need to be retrieved, so these can later be evaluated

We have obtained the Forms of the answers, we make a call for the notebooks. Here is read with the following step, a list of available notebooks.

The notebook ID...

We now have the contents of the Forms of response, and a list of notebooks available. In the next section, we need to find the right notebook out, and the unique notebook Key find. With this Key, we continue to work later.

That is the right notebook filter from the list. To do this, we filter the notebook list on the notebook, which of the users in the Forms listed. To do this, we use the function filter Array.

In the function, we rst select from the Dynamic content of the "body". Then we look for the same file name as the person Applying it in the Forms specified,

Thus, we now have access to the correct OneNote notebook. As mentioned above, we need many more steps to the notebook key (Key). About the Filter, we get two values. The name and the Key.

 { "FileName": "Team OneNote Template",    
„Key“: „TeamsOneNoteTemplate|$|https://contexxtai.sharepoint.com/sites/Office365Training/Shared Documents/General/TeamsOneNoteTemplate“  },

As a result, we need to reduce this total string only on the Key value. I'll take that for what is happening in the next four steps.

  1. We put a findable unique character of the Key. To this end, we write at the end of "EOF" for EndOfFile

  2. Then we search for the start position where the notebook key starts

  3. Now we need the end of the notebook key

  4. and at the end, we now read the key with the previously determined Start and end values.

So we have to act now, the key in the Hand in order to continue.

The Template...

To start with the Template, we have been chosen which Template to look in the Forms. This can be represented with nested conditions.

In my example, we will first look if the Template "Project" was selected. If not, we ask in the no branch to the next Template, etc.

If so, we build on the OneNote notebook structure with sections, pages, and page content.

The Structure Of...

We'll put you first all the desired sections for the selected Template. To do this, we use the function "create a section in a notebook".

The function requires two parameters. The Name of the section and the previously determined notebook key:

After the sections have been created, we need to have more pages. To do this we must first download the new sections only again to be able to work with it. This is also an action is to be provided to the notebook key as a Parameter needs.

Then, we filter on one of the newly created sections of a page with content to create.

In the Parameter of the result of the action is entered to retrieve "sections in notebook":

After we have selected the section now, let's get the section ID in a Variable.

The section ID and the Notebook, we need to create a new page. To do this, you use the create action "page in a section":

Noch ein Tipp beim erstellen des Seiteninhaltes mit dieser Aktion. Klickt auf das Symbol </> in der Formatierungsleiste um eine HTML Syntax zu verwenden. Dadurch kann man direkt auch den Seitentitel mit anlegen.

Example HTML Snippet:

<html>
<head>
<title>Kickoff-Meeting</title>
</head>
<body>
<h3>Agenda</h3>
<ul>
  <li>Topic 1</li>
  <li>Topic 2</li>
  <li>Topic 3</li>
</ul>
</body>

A Block of actions is repeated should be for each page created:

So now you have to actually assemble all the tools together to OneNote-Template-Generator on. I hope One or the Other can use the good and also like to develop further.

Here again, the function and the sequence of the example, as a Video to watch: