web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Changing the name of a...
Power Automate
Unanswered

Changing the name of a one note notebook through automate

(0) ShareShare
ReportReport
Posted on by 120
 
 

I am tasked with creating a system that copies a series of folders and subfolders. I got the system to copy these folders but need to rename the main folder name to the project number and also rename the onenote file inside of that folder. Does anyone know what logic to apply to this or even info that can help program this in powerautomate? I have attached a photo of the system and highlighted the parts I need to rename.

Categories:
I have the same question (0)
  • Expiscornovus Profile Picture
    33,183 Most Valuable Professional on at

    Hi @zajacjos,

     

    A OneNote is a bunch of files in a folder. If you want to rename the whole Notebook you can rename that folder. You can use the MERGE method from the REST API for that. 

     

    Below is an example.

     

    1. In the first part of the flow I am creating the folders from an array. And copying an existing notebook template via the copy folder.

     

    folderstructure_creation.png

     

    2. In the second part I am retrieving the Odata type via a GET request and using a POST with a MERGE to rename the folder/onenote.

     

    body('Send_an_HTTP_request_to_SharePoint')['d']['__metadata']['type']

     

    rename_onenote_spo.png

     

    This should result in something like below

     

    projetfolderstructure.png

  • zajacjos Profile Picture
    120 on at

    I tried your code and it will not change the project folder name or the onenote file. Do you see an discrepancies?

  • zajacjos Profile Picture
    120 on at

    here is the final page and result

  • Expiscornovus Profile Picture
    33,183 Most Valuable Professional on at

    Hi @zajacjos,

     

    Below are a couple of thing which I would change for the setup in screenshots of page1, page2 and page3.

     

    1. Change Project Number and Title variables to Type String.

     

    feedback01.png

     

    2. Remove the Folder Name from the List or Library field. Remove the Library name from the Folder Path field.

     

    feedback02.png

     

    3. Update the RelativeUrl in the Uri field of both Send an HTTP request actions to use your automation site and not the site from my example (PowerUsers). Correct the small typo of the Content-Type header. The word verbos is missing an e. (should be verbose).

     

    feedback03.png

  • zajacjos Profile Picture
    120 on at

    I made some updates and now no file appears in project folders anymore! Are you allowed to accept tips? I really appreciate the help, I didnt even think it would be possible to update it.

  • Expiscornovus Profile Picture
    33,183 Most Valuable Professional on at

    Hi @zajacjos,

     

    Here is a step-by-step walkthrough of the setup, if that helps?

     

    I will update this post with some screenshots as well.

     

    1. When an item is created

    a. Use the Site Address you want

    b. Use your Project Numbers list

     

    whenanitemiscreated.png

     

    2. Add Initialize variable action

    a. Use ProjectNumber as Name

    b. Select Type String

    c. Use Project# as value

     

    projectnumber.png

     

    3. Add Initialize variable action

    a. Use Title as Name

    b. Select Type String

    c. Use Title as value

     

    title.png

     

    4. Add Initialize variable action

    a. Use FolderStructureArray as Name

    b. Select Type Array

    c. Use an array like below as value

     

     

    [
     "1.Proposal",
     "2.Quote",
     "3.Purchase Order"
    ]

     

     

    folderstructurearray.png

     

    5. Add an apply to each.

    a. Use the FolderStructureArray in the Select an output from previous steps

     

    6. Add an Create new folder (within the apply to each)

    This will create the folder structure based on the items of the array

     

    a. Select Site Address

    b. Select the Library, Project Folders

    c. Use the following value for the Folder Path

     

    /@{variables('ProjectNumber')}_@{variables('Title')}/@{item()}

     

     

    createnewfolder.png

     

    7. Add a Copy Folder action

    This action only copies the OneNote to the new Project Folder location

     

    a. Select Current Site Address

    b. Select the Location of the OneNote template

     

    /Project Folders/Template OneNote

     

    c. Select Destination Site Address

    d. Select the Destination of the OneNote tempalte

     

    /Project Folders/@{variables('ProjectNumber')}_@{variables('Title')}

     

     

    copyfolder.png

     

    8. Add a Send an HTTP request

    This action is to retrieve the Odata type value for the next action

     

    a. Select the Site Address

    b. Use the GET Method

    c. Use the following URI

     

    _api/web/GetFolderByServerRelativeUrl('/sites/automation/@{outputs('Copy_folder')?['body/Path']}')/ListItemAllFields

     

    d. Use the following Headers

     

    {
     "Accept": "application/json;odata=verbose",
     "Content-Type": "application/json;odata=verbose"
    }

     

     

    uri_example.png

     

    9. Add a Send an HTTP request

    With this action we rename the OneNote folder

     

    a. Select the Site Address

    b. Use the POST Method

    c. Use the following URI

     

    _api/web/GetFolderByServerRelativeUrl('/sites/automation/@{outputs('Copy_folder')?['body/Path']}')/ListItemAllFields

     

    d. Use the following Headers

     

    {
     "Accept": "application/json;odata=verbose",
     "Content-Type": "application/json;odata=verbose",
     "If-Match": "*",
     "X-HTTP-Method": "MERGE"
    }

     

    e. Use the following Body

     

    {
     "__metadata": {
     "type": "@{body('Send_an_HTTP_request_to_SharePoint')['d']['__metadata']['type']}"
     },
     "Title": "@{variables('ProjectNumber')}_@{variables('Title')}",
     "FileLeafRef": "@{variables('ProjectNumber')}-@{variables('Title')}"
    }

     

     

    uri_example02.png

  • zajacjos Profile Picture
    120 on at

    I am confused with the copy folder address 

    zajacjos_0-1668011189691.png

    This is the address I used but feel like its incorrect

    zajacjos_1-1668011220928.png

    Can you explain how I get the correct destination address as I keep getting errors with step 7 and 8

     

     

  • Expiscornovus Profile Picture
    33,183 Most Valuable Professional on at

    Hi @zajacjos,

     

    In the setup I shared the OneNote is stored in the root of the library.

     

    If it is located in a different place in your setup you should select the correct location of the OneNote folder for the Folder to Copy field value. You can select it via that folder icon on the right hand side.

     

    endresult02.png

     

     

    To clarify. This was the setup I used.

     

    templateisinroot.png

     

    And this was the end result for a project with number PRJ-001 and a title Test

     

    endresult.png

  • zajacjos Profile Picture
    120 on at

     

    I moved the OneNote so it followed the same folder structure as you I believe this fixed the copy problem but the next step is either pointing incorrectly or I missed something

    zajacjos_3-1668017582137.png

     

    this is the URI being outputted and the file structure seems off: _api/web/GetFolderByRelativeUri('/sites/automation/Project Folders/2088_test/XXXX_Project Description')/ListItemAllFields

    zajacjos_4-1668017608608.pngzajacjos_5-1668017635380.png

    zajacjos_6-1668017784033.png

     

  • zajacjos Profile Picture
    120 on at

    Also is there a way to use the array you helped me to create to add subfolders to 1.Proposal ? I need this structure and realized that since I stopped copying the the template that it no longer gets created.

    zajacjos_7-1668020333218.png

     

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 523 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 406 Moderator

#3
abm abm Profile Picture

abm abm 245 Most Valuable Professional

Last 30 days Overall leaderboard