Microsoft Flow: Copy OneNote Notebook

Why?

Let’s say we have a template library and we have a OneNote Template Notebook in there that we want to use as a template for other libraries or sub folders. It should be very simple like my previous post (view it for related info like used variables below) : https://knowhere365.space/microsoft-flow-create-a-file-based-on-another-file-in-sharepoint/… when you realize that a OneNote Notebook actually is a special kind of Folder the Get file content acftion will result in a failed error.

What?

This post will explain on how we can use the relatively new action: Copy folder to get a full OneNote Notebook copied.

How?

1) First you want to get the OneNote Template Notebook using the Get files (properties only) action:

I use a substringof function in the Filter Query to make sure that I only get the OneNote Template Notebook. See https://knowhere365.space/microsoft-flow-odata-filter-query/ for more OData filter query information.

2) Then simply copy the OneNote Template Notebook using the Copy folder action with the Identifier property of the previous action:

Microsoft Flow will probably put this action into an Apply to each action because of possible multiple outputs so don’t be frightened 😱.

3) Optionally you may want to change the name of the OneNote Template Notebook: untill it is possible to rename the file in the same copy action we need to use the Send an HTTP request to SharePoint action:

Uri:

/_api/web/GetFolderByServerRelativeUrl('bidMGM_Documents/@{variables('varItemName')}/TemplateNotebook')/ListItemAllFields

Headers:

{
  "Accept": "application/json;odata=verbose",
  "X-HTTP-Method": "MERGE",
  "IF-MATCH": "*"
}

Body:

{
'Title':'@{variables('varItemName')}_Notebook',
'FileLeafRef':'@{variables('varItemName')}_Notebook'
}

2 thoughts on “Microsoft Flow: Copy OneNote Notebook

  1. Hi, Thank you very much for your example copying a OneNote notebook with Office 365 Flow. Do you also have any idea, how to retrieve the key of the created OneNote notebook? My plan is, after cloning the OneNote notebook, storing the key in a SharePoint list, for further use in different Flows.

Leave a comment