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

Flow trigger Onedrive copy file and Excel to delelet all rows in Excel for business

Hi I have a powerapps that stores audit trail records in a table named "audit_trail" and the file is stored in Onedrive for business. I afraid the table is getting bloated and would like to automate a monthly audit trail purge, I am new to Flow and when testing with the flow setup, I have some problems:

无标题.png

  1. When I copy a file to another folder in Onedrive, I do not want to overwrite the existing file (i.e. in case audit.xlsx already exist) I would instead want to add a date suffix to the file (i.e. audit_OCT1.xlsx) or increasing number (i.e. audit_1.xlsx) to prevent the File already exisit error when triggering the flow. Is there anyway to do this?
  2. After copying the file, I would like to delete all rows(that is not blank) form the original track_now.xlsx-audit_trail table, I am thinking to set delete rows that has non blank "_PowerAppsid_" but I cant seems to get it to work, may I have some suggestions on this

 

1 ACCEPTED SOLUTION

Accepted Solutions
Community Support Team
Community Support Team

Re: Flow trigger Onedrive copy file and Excel to delelet all rows in Excel for business

 

Hi @VinL ,

 

For the first problem, using the Copy file action does not allow you to change the file name. You could refer to the following method.

Use the Create file action to do the same thing as copying a file.

And use the following expression to add a date to the file name.

concat(body('Get_file_metadata_using_path')?['NameNoExt'],'-',utcNow('yyyy-MM-dd'),'.',last(split(body('Get_file_metadata_using_path')?['Name'],'.')))

Image reference:

72.PNG

For the second question, you need to use List rows present in a table action to get all the rows, and then determine whether the specified field is empty. If it is not empty, delete the current rows.

You can use _PowerAppsId_ field, which is a field with a unique value.

Image reference:

73.PNG

 

Best Regards,

Community Support Team _ Barry
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

3 REPLIES 3
Community Support Team
Community Support Team

Re: Flow trigger Onedrive copy file and Excel to delelet all rows in Excel for business

 

Hi @VinL ,

 

For the first problem, using the Copy file action does not allow you to change the file name. You could refer to the following method.

Use the Create file action to do the same thing as copying a file.

And use the following expression to add a date to the file name.

concat(body('Get_file_metadata_using_path')?['NameNoExt'],'-',utcNow('yyyy-MM-dd'),'.',last(split(body('Get_file_metadata_using_path')?['Name'],'.')))

Image reference:

72.PNG

For the second question, you need to use List rows present in a table action to get all the rows, and then determine whether the specified field is empty. If it is not empty, delete the current rows.

You can use _PowerAppsId_ field, which is a field with a unique value.

Image reference:

73.PNG

 

Best Regards,

Community Support Team _ Barry
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

VinL
Level: Powered On

Re: Flow trigger Onedrive copy file and Excel to delelet all rows in Excel for business

or the "determine whether the specified field is empty", i just leave "not equal to" value blank in the condition? or I need to use Null fucnction in not equal to?

Community Support Team
Community Support Team

Re: Flow trigger Onedrive copy file and Excel to delelet all rows in Excel for business

 

Just leave "not equal to" value blank

 

Best Regards,

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

Helpful resources

Announcements
firstImage

Power Platform Online Conference

Join us for the first ever Power Platform Online Conference!

firstImage

Incoming: New and improved badges!

Look out for new contribution recognition badges coming SOON!

firstImage

New & Improved Power Automate Community Cookbook

We've updated and improved the layout and uploading format of the Power Automate Cookbook!

thirdimage

Power Automate Community User Group Member Badge

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

sixthImage

Power Platform World Tour

Find out where you can attend!

seventhimage

Webinars & Video Gallery

Watch & learn from the Power Automate Community Video Gallery!

Top Solution Authors
Top Kudoed Authors
Users online (4,704)