cancel
Showing results for 
Search instead for 
Did you mean: 
Reply

Changing a file name in sharepoint

Hello again!

Trying to create a flow where paper documents are scanned in, their contents saved to SharePoint and the files are named with a shipment number contained on the paper documents. 

The scanner sends the scan to an email address which triggers a flow that saves the attachment to sharepoint.

I have a second flow that is triggered when a document is created in the sharepoint folder. An AI model that extracts a shipment number form the scan image.

The bit I'm stuck on is I now want to rename the scan document to be the same as the shipment number. I have tried using the create file and copy file options but havnt had much luck.  
When I did the create file option - it created a file successfully with the shipment number as the name, but it was just a blank file.
When Im trying the copy file, I can figure out how to change the name.

(The teams message is just for testing so that I knew the AI bit was working)

adrianm_0-1647013897911.png

 





1 ACCEPTED SOLUTION

Accepted Solutions

Hi @adrian-m - more like this, using the Expression menu. 

 

expression3.gif

View solution in original post

22 REPLIES 22
ScottShearer
Most Valuable Professional
Most Valuable Professional

@adrian-m 

Essentially, you'll need to create a new file with the new name and delete the original when you're done.

Here is a link to a blog post that explains all but the delete.

The problem that you'll have is that you'll create an infinite loop - the Flow will run again when the new file is created.   You might add a condition that says of the file was created by you, then exit the Flow to work around this issue.

 

If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

Scott

Here is another method which uses the file check out and check in actions:

Renaming a SharePoint file using REST API with Power Automate

 


Ellis
____________________________________
If I have answered your question, please mark the post as Solved.
If you like my response, please give it a Thumbs Up.

thanks for the reply, in the get file content action - which file identifier should i use? (Im not sure this method will even work - it wants me to specify a single existing document rather than anyway to get it to dynamically do it for files in a folder)

New files may come in quickly - the users stand at tray fed scanner and just pour orders in, one email/pdf will be created per order but they might do 20 orders one after another. So PDF's might stack up in the folder - Cant have the flow relying on there only being a single document in the folder to work. 
When a document is created - we need to specifically identify that document that was just created regardless of what else is in the folder.

adrianm_0-1647095389847.png

 

Try using one of the When a file is created triggers, for example:

Snag_f7f1d2d.png

Ellis

seems like i need two triggers? When a File is created (properties only) - to get the file ID and "When a file is created" in order to get the file contents.

However when I try to use two triggers teh flow just stalls on the second trigger 😞 (i assume you cant have 2 in the same flow?)

The flow should only use one trigger. Start with a simple flow, using the When a File is created (properties only) trigger, then get the file content using path for use in your AI builder action.

 

Ellis

file contents doesnt seem to be an option from the AI model action. 

Also, it seems the AI model action wont work with the Properties only "when a file is created" - it cant get the file contents to work on

Can you try something like this?

Snag_149f18e9.png

Ellis

Nice use case for AI Builder @adrian-m!

 

Here is an example flow of how this can be achieved. Here I'm using the extracted value 'Sales order number value' returned by the AI Builder model as the new name of the file.

 

JoeFMSFT_0-1647184263816.png

 

The following link explains in more details the Send an HTTP request to SharePoint action: Rename a file in SharePoint with a single Power Automate action (tomriha.com)

Thanks for the reply....I am getting an error on the http request -


{
  "status"404,
  "message""List 'Documents/Shared Documents/Inbound Files' does not exist at site with URL 'https://company.sharepoint.com/sites/SBTransport528'.\r\nclientRequestId: 1aedddc2-bb9b-48cd-b074-fdf1e5025953\r\nserviceRequestId: 799f29a0-608e-3000-ec2a-ba1888d3e6c6",
  "errors": [
    "-1",
    "System.ArgumentException"
  ]
}



and yet it can find that location just fine with the trigger and when creating the file at the beginning etc

I've tried every possible combination of file path I can think of 😞

NEVER MIND!  lol

I went back to trying to use the "create file" action which created documents that I thought were just blank - but then i Downloaded one and noticed its file size was significant. Realised the file was being created just fine only without the file extension which I have now fixed 😄


One last question - the shipping numbers are all in the format 4000789654  is there an easy way to truncate the leading 4000 ?

adrianm_0-1647256284741.png

 

Hi @adrian-m - congrats on successfully building this automation! 🙂

 

Apologies for taking some time to response to your last question. The following expression should take care of truncating the first four digits:

 

substring(Put here the shipping number output, 4, sub(length(Put here the shipping number output), 4))

like this?

adrianm_0-1647944555156.png

 

Hi @adrian-m - more like this, using the Expression menu. 

 

expression3.gif

thats worked perfectly thanks!!!

Power Automate now has a new function called slice. See: Reference guide for expression functions - Azure Logic Apps | Microsoft Docs

Example:

ekarim2020_0-1648024818646.png

slice('4000789654',4) returns 789654
 
Hope this helps.
 
Ellis
 
 

I am getting an error in "Send HTTP Request" step where the file cannot be found.

My files are actually in a subfolder of "Documents" called TermList

Both Trigger and GET file Metadata work fine to ID the actual file.

 

All i need to accomplish is to rename the file from xyz.csv to xyz.xlsx - change filetype.

 

I have tried several iterations of the folder structure in the uri 

GetByTitle('Documents/TermList')/items

... ('Shared Documents/TermList')/items

neither work..

reidb_0-1672355479102.png

error: (with a different file path, but get same error no matter what path i put in)

reidb_1-1672355549219.png

 

Hi @reidb - what you should put in the URI is the name of the document library. By default in many cases is Documents. Here is where you see it in SharePoint:

 

JoeFMSFT_0-1672498153571.png

 

Have you tried with: _api/web/lists/GetByTitle('Documents')/items(<PUT YOUR FILE ID HERE>)/validateUpdateListItem 

 

Happy new year! 🎇

Helpful resources

Announcements

Community will be READ ONLY July 16th, 5p PDT -July 22nd

Dear Community Members,   We'd like to let you know of an upcoming change to the community platform: starting July 16th, the platform will transition to a READ ONLY mode until July 22nd.   During this period, members will not be able to Kudo, Comment, or Reply to any posts.   On July 22nd, please be on the lookout for a message sent to the email address registered on your community profile. This email is crucial as it will contain your unique code and link to register for the new platform encompassing all of the communities.   What to Expect in the New Community: A more unified experience where all products, including Power Apps, Power Automate, Copilot Studio, and Power Pages, will be accessible from one community.Community Blogs that you can syndicate and link to for automatic updates. We appreciate your understanding and cooperation during this transition. Stay tuned for the exciting new features and a seamless community experience ahead!

Summer of Solutions | Week 4 Results | Winners will be posted on July 24th

We are excited to announce the Summer of Solutions Challenge!    This challenge is kicking off on Monday, June 17th and will run for (4) weeks.  The challenge is open to all Power Platform (Power Apps, Power Automate, Copilot Studio & Power Pages) community members. We invite you to participate in a quest to provide solutions to as many questions as you can. Answers can be provided in all the communities.    Entry Period: This Challenge will consist of four weekly Entry Periods as follows (each an “Entry Period”)   - 12:00 a.m. PT on June 17, 2024 – 11:59 p.m. PT on June 23, 2024 - 12:00 a.m. PT on June 24, 2024 – 11:59 p.m. PT on June 30, 2024 - 12:00 a.m. PT on July 1, 2024 – 11:59 p.m. PT on July 7, 2024 - 12:00 a.m. PT on July 8, 2024 – 11:59 p.m. PT on July 14, 2024   Entries will be eligible for the Entry Period in which they are received and will not carryover to subsequent weekly entry periods.  You must enter into each weekly Entry Period separately.   How to Enter: We invite you to participate in a quest to provide "Accepted Solutions" to as many questions as you can. Answers can be provided in all the communities. Users must provide a solution which can be an “Accepted Solution” in the Forums in all of the communities and there are no limits to the number of “Accepted Solutions” that a member can provide for entries in this challenge, but each entry must be substantially unique and different.    Winner Selection and Prizes: At the end of each week, we will list the top ten (10) Community users which will consist of: 5 Community Members & 5 Super Users and they will advance to the final drawing. We will post each week in the News & Announcements the top 10 Solution providers.  At the end of the challenge, we will add all of the top 10 weekly names and enter them into a random drawing.  Then we will randomly select ten (10) winners (5 Community Members & 5 Super Users) from among all eligible entrants received across all weekly Entry Periods to receive the prize listed below. If a winner declines, we will draw again at random for the next winner.  A user will only be able to win once overall. If they are drawn multiple times, another user will be drawn at random.  Individuals will be contacted before the announcement with the opportunity to claim or deny the prize.  Once all of the winners have been notified, we will post in the News & Announcements of each community with the list of winners.   Each winner will receive one (1) Pass to the Power Platform Conference in Las Vegas, Sep. 18-20, 2024 ($1800 value). NOTE: Prize is for conference attendance only and any other costs such as airfare, lodging, transportation, and food are the sole responsibility of the winner. Tickets are not transferable to any other party or to next year’s event.   ** PLEASE SEE THE ATTACHED RULES for this CHALLENGE**   Week 1 Results: Congratulations to the Week 1 qualifiers, you are being entered in the random drawing that will take place at the end of the challenge.   Community MembersNumber SolutionsSuper UsersNumber Solutions Deenuji 9 @NathanAlvares24  17 @Anil_g  7 @ManishSolanki  13 @eetuRobo  5 @David_MA  10 @VishnuReddy1997  5 @SpongYe  9JhonatanOB19932 (tie) @Nived_Nambiar  8 @maltie  2 (tie)   @PA-Noob  2 (tie)   @LukeMcG  2 (tie)   @tgut03  2 (tie)       Week 2 Results: Congratulations to the Week 2 qualifiers, you are being entered in the random drawing that will take place at the end of the challenge. Week 2: Community MembersSolutionsSuper UsersSolutionsPower Automate  @Deenuji  12@ManishSolanki 19 @Anil_g  10 @NathanAlvares24  17 @VishnuReddy1997  6 @Expiscornovus  10 @Tjan  5 @Nived_Nambiar  10 @eetuRobo  3 @SudeepGhatakNZ 8     Week 3 Results: Congratulations to the Week 3 qualifiers, you are being entered in the random drawing that will take place at the end of the challenge. Week 3:Community MembersSolutionsSuper UsersSolutionsPower Automate Deenuji32ManishSolanki55VishnuReddy199724NathanAlvares2444Anil_g22SudeepGhatakNZ40eetuRobo18Nived_Nambiar28Tjan8David_MA22   Week 4 Results: Congratulations to the Week 4 qualifiers, you are being entered in the random drawing that will take place at the end of the challenge. Week 4:Community MembersSolutionsSuper UsersSolutionsPower Automate Deenuji11FLMike31Sayan11ManishSolanki16VishnuReddy199710creativeopinion14Akshansh-Sharma3SudeepGhatakNZ7claudiovc2CFernandes5 misc2Nived_Nambiar5 Usernametwice232rzaneti5 eetuRobo2   Anil_g2   SharonS2  

Check Out | 2024 Release Wave 2 Plans for Microsoft Dynamics 365 and Microsoft Power Platform

On July 16, 2024, we published the 2024 release wave 2 plans for Microsoft Dynamics 365 and Microsoft Power Platform. These plans are a compilation of the new capabilities planned to be released between October 2024 to March 2025. This release introduces a wealth of new features designed to enhance customer understanding and improve overall user experience, showcasing our dedication to driving digital transformation for our customers and partners.    The upcoming wave is centered around utilizing advanced AI and Microsoft Copilot technologies to enhance user productivity and streamline operations across diverse business applications. These enhancements include intelligent automation, AI-powered insights, and immersive user experiences that are designed to break down barriers between data, insights, and individuals. Watch a summary of the release highlights.    Discover the latest features that empower organizations to operate more efficiently and adaptively. From AI-driven sales insights and customer service enhancements to predictive analytics in supply chain management and autonomous financial processes, the new capabilities enable businesses to proactively address challenges and capitalize on opportunities.    

Updates to Transitions in the Power Platform Communities

We're embarking on a journey to enhance your experience by transitioning to a new community platform. Our team has been diligently working to create a fresh community site, leveraging the very Dynamics 365 and Power Platform tools our community advocates for.  We started this journey with transitioning Copilot Studio forums and blogs in June. The move marks the beginning of a new chapter, and we're eager for you to be a part of it. The rest of the Power Platform product sites will be moving over this summer.   Stay tuned for more updates as we get closer to the launch. We can't wait to welcome you to our new community space, designed with you in mind. Let's connect, learn, and grow together.   Here's to new beginnings and endless possibilities!   If you have any questions, observations or concerns throughout this process please go to https://aka.ms/PPCommSupport.   To stay up to date on the latest details of this migration and other important Community updates subscribe to our News and Announcements forums: Copilot Studio, Power Apps, Power Automate, Power Pages

Users online (803)