cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
mardex
Level: Powered On

Flow Deleting old Versions on Sharepoint

Good day,

 

I have to run a flow each day to update datas. When I run them a new Version of the document is always created.

I have around 24 GB of Datas, Each File multiplied by 100. 
So I have 1,4 TB of data and my Storage is full.

 

MY QUESTION: Does anybody know how to delete all old Versions of a File in Sharepoint as it is not possible to set Versions to a lower Number then 100

 

Thanks


BRGDS
Jan Held

2 ACCEPTED SOLUTIONS

Accepted Solutions
mardex
Level: Powered On

Re: Flow Deleting old Versions on Sharepoint

I mean delete with FLOW!!!! not manually


@mardex wrote:

Good day,

 

I have to run a flow each day to update datas. When I run them a new Version of the document is always created.

I have around 24 GB of Datas, Each File multiplied by 100. 
So I have 1,4 TB of data and my Storage is full.

 

MY QUESTION: Does anybody know how to delete all old Versions of a File in Sharepoint as it is not possible to set Versions to a lower Number then 100

 

Thanks


BRGDS
Jan Held


 

View solution in original post

Community Support Team
Community Support Team

Re: Flow Deleting old Versions on Sharepoint

Hi @mardex,

 

Please refer to the following steps to delete the old versions of each file in the SharePoint library:

 

Step 1: Add Get files(properties only) action to get files in the list.

Step 2: Add Send an HTTP request to SharePoint

Method: GET
Uri: _api/web/GetFolderByServerRelativeUrl('Dynamic content of Folder Path')/Files('Dynamic content of File name with extension')/Versions

Annotation 2019-08-29 150852.pngStep 3: Parse JSON, put the body of the previous action into the Content of Parse JSON action, then click the button "Use sample payload" to generate schema to paste the following schema:

{
"type": "object",
"properties": {
"d": {
"type": "object",
"properties": {
"results": {
"type": "array",
"items": {
"type": "object",
"properties": {
"__metadata": {
"type": "object",
"properties": {
"id": {
"type": "string"
},
"uri": {
"type": "string"
},
"type": {
"type": "string"
}
}
},
"CreatedBy": {
"type": "object",
"properties": {
"__deferred": {
"type": "object",
"properties": {
"uri": {
"type": "string"
}
}
}
}
},
"CheckInComment": {
"type": "string"
},
"Created": {
"type": "string"
},
"ID": {
"type": "integer"
},
"IsCurrentVersion": {
"type": "boolean"
},
"Length": {
"type": "string"
},
"Size": {
"type": "integer"
},
"Url": {
"type": "string"
},
"VersionLabel": {
"type": "string"
}
},
"required": [
"__metadata",
"CreatedBy",
"CheckInComment",
"Created",
"ID",
"IsCurrentVersion",
"Length",
"Size",
"Url",
"VersionLabel"
]
}
}
}
}
}
}

 

Annotation 2019-08-29 151226.png

Step 4: Create the other Send an Http request to SharePoint:

Method: DELETE
Uri: _api/web/GetFolderByServerRelativeUrl('Dynamic content of Folder Path')/Files('Dynamic content of File name with extension')/Versions(ID from the previous action)

Please have a try, I hope it can help you.

 

Best Regards,
Community Support Team _ Lin Tu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

4 REPLIES 4
mardex
Level: Powered On

Re: Flow Deleting old Versions on Sharepoint

I mean delete with FLOW!!!! not manually


@mardex wrote:

Good day,

 

I have to run a flow each day to update datas. When I run them a new Version of the document is always created.

I have around 24 GB of Datas, Each File multiplied by 100. 
So I have 1,4 TB of data and my Storage is full.

 

MY QUESTION: Does anybody know how to delete all old Versions of a File in Sharepoint as it is not possible to set Versions to a lower Number then 100

 

Thanks


BRGDS
Jan Held


 

View solution in original post

Super User
Super User

Re: Flow Deleting old Versions on Sharepoint

@mardex 

To delete old versions, you'll need to use the SharePoint HTTP action and call a SharePoint web service.  I can't provide the specifics, but that's the route you'll need to go.  Another way to approach this might be to create a new document (based on the old document including metadata) and delete the old one rather than updating the existing documents in your Flow.

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

Scott
mardex
Level: Powered On

Re: Flow Deleting old Versions on Sharepoint

thanks, I expected this. So it will be a hell of work for me as a non professional Smiley Sad


@ScottShearer wrote:

@mardex 

To delete old versions, you'll need to use the SharePoint HTTP action and call a SharePoint web service.  I can't provide the specifics, but that's the route you'll need to go.  Another way to approach this might be to create a new document (based on the old document including metadata) and delete the old one rather than updating the existing documents in your Flow.


 

Community Support Team
Community Support Team

Re: Flow Deleting old Versions on Sharepoint

Hi @mardex,

 

Please refer to the following steps to delete the old versions of each file in the SharePoint library:

 

Step 1: Add Get files(properties only) action to get files in the list.

Step 2: Add Send an HTTP request to SharePoint

Method: GET
Uri: _api/web/GetFolderByServerRelativeUrl('Dynamic content of Folder Path')/Files('Dynamic content of File name with extension')/Versions

Annotation 2019-08-29 150852.pngStep 3: Parse JSON, put the body of the previous action into the Content of Parse JSON action, then click the button "Use sample payload" to generate schema to paste the following schema:

{
"type": "object",
"properties": {
"d": {
"type": "object",
"properties": {
"results": {
"type": "array",
"items": {
"type": "object",
"properties": {
"__metadata": {
"type": "object",
"properties": {
"id": {
"type": "string"
},
"uri": {
"type": "string"
},
"type": {
"type": "string"
}
}
},
"CreatedBy": {
"type": "object",
"properties": {
"__deferred": {
"type": "object",
"properties": {
"uri": {
"type": "string"
}
}
}
}
},
"CheckInComment": {
"type": "string"
},
"Created": {
"type": "string"
},
"ID": {
"type": "integer"
},
"IsCurrentVersion": {
"type": "boolean"
},
"Length": {
"type": "string"
},
"Size": {
"type": "integer"
},
"Url": {
"type": "string"
},
"VersionLabel": {
"type": "string"
}
},
"required": [
"__metadata",
"CreatedBy",
"CheckInComment",
"Created",
"ID",
"IsCurrentVersion",
"Length",
"Size",
"Url",
"VersionLabel"
]
}
}
}
}
}
}

 

Annotation 2019-08-29 151226.png

Step 4: Create the other Send an Http request to SharePoint:

Method: DELETE
Uri: _api/web/GetFolderByServerRelativeUrl('Dynamic content of Folder Path')/Files('Dynamic content of File name with extension')/Versions(ID from the previous action)

Please have a try, I hope it can help you.

 

Best Regards,
Community Support Team _ Lin Tu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

Helpful resources

Announcements
firstImage

Microsoft Business Applications Virtual Launch Event

Watch the event on demand for an in-depth look at the new innovations across Dynamics 365 and the Microsoft Power Platform.

firstImage

Watch Sessions On Demand!

Continue your learning in our online communities.

Power Platform 2019 Release Wave 2 Plan

Power Platform 2019 Release Wave 2 Plan

Features releasing from October 2019 through March 2020.

thirdimage

Flow Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

fifthimage

Microsoft Learn

Learn how to build the business apps that you need.

sixthImage

Power Platform World Tour

Find out where you can attend!

seventhimage

Webinars & Video Gallery

Watch & learn from the Flow Community Video Gallery!

Users Online
Currently online: 162 members 4,669 guests
Please welcome our newest community members: