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 / Publish an existing Sh...
Power Automate
Answered

Publish an existing SharePoint file

(0) ShareShare
ReportReport
Posted on by 24
I have a flow that roughly does the following:
  1.  Triggered when an email arrives from a particular sender
  2.  Gets the list of files in a particular SharePoint folder
  3.  Checks to see if there is a file with the same name as the Subject of the email
  4.  If there isn't, it stops. If there is, it checks to see if the email has an attachment
  5.  If there's an attachment, it updates the file content with the attachment content
The problem I have run into is that after this running successfully for months, I've hit the SharePoint minor version number limit (511 versions) for some of the files which has caused the update step to fail. I have temporarily resolved the issue by manually publishing all the files in the folder but I'm looking for a way to make sure this never happens in future.
 
I thought there might be a SharePoint "Publish file" action in PA online but there doesn't seem to be one. Does anyone know how you can publish a file with an online flow?
TIA
Categories:
I have the same question (0)
  • Suggested answer
    David_MA Profile Picture
    12,970 Super User 2025 Season 2 on at
    I am sure I found this elsewhere on the Web, but it has been so long since I set this up, I have forgotten where I got this solution. Do this:
     
    1. Initialize a Boolean variable named Checked Out and set the default value as false.
    2. Initialize another Boolean variable named Updated and set the default value to false.
    3. Initialize a string variable and set the default value to the URL of your SharePoint site (e.g., https://domain.sharepoint.com/sites/yoursitename/)
    4. Initialize a string variable named RelativePath and set the default value to your site URL without the domain (e.g., /sites/yoursitename)
    5. Add a Do until action (I name it Checked Out) and set it to run until Checked Out is equal to true
    6. Inside the do until, add the following actions:
      1. HTTP POST request configured to your SharePoint site.
        1. Set the Uri to /_api/web/GetFileByServerRelativeUrl('@{variables('RelativePath')}@{triggerOutputs()?['body/{FullPath}']}')/CheckOut()
        2. Note: my trigger is When a file is created (properties only) and the triggerOutputs()?['body/{FullPath}'] comes from this trigger.
      2. Add a set variable action and set the Checked Out variable to True.
      3. In parallel, add a delay action with a 5 minute delay. Set the delay action to only run if the HTTP request fails.
    7. Add another Do until action (I named it Updated) and set it to run until Updated is equal to true
    8. Inside the do until, add the following actions:
      1. HTTP POST request configured to your SharePoint site.
        1. Set the Uri to /_api/web/GetFileByServerRelativeUrl('@{variables('RelativePath')}@{triggerOutputs()?['body/{FullPath}']}')/CheckIn(comment='New Request Submitted for Review',checkintype=1)
        2. Note: my trigger is When a file is created (properties only) and the triggerOutputs()?['body/{FullPath}'] comes from this trigger. You can make the comment anything you want, although I would stick to something simple and has no special characters that would cause malformed JSON.
      2. Add a set variable action and set the Checked Out variable to True.
      3. In parallel, add a delay action with a 5 minute delay. Set the delay action to only run if the HTTP request fails.
    The flow will look like this:
     
    You may find this helpful, as it describes the SharePoint API call I am using to publish a major version of the file: Publishing Major Versions of Files in SharePoint with Power Automate | Blog about anything related to my learnings
  • Verified answer
    markbowler7 Profile Picture
    24 on at
    Thanks @David_MA, I realised while I was looking at the detail of your solution that in fact I could just use the "Check in file" action because it has a flag to indicate whether this is a minor or major version:
     
    Hence I just modified my flow to check the file out before step 5, then check in again with the fag set to Major.

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 503 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 321 Moderator

#3
abm abm Profile Picture

abm abm 237 Most Valuable Professional

Last 30 days Overall leaderboard