cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
VinL
Frequent Visitor

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
v-bacao-msft
Community Support
Community Support

 

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
v-bacao-msft
Community Support
Community Support

 

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.

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?

v-bacao-msft
Community Support
Community Support

 

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
Register for a Free Workshop.png

Register for a Free Workshop

Learn to digitize and optimize business processes and connect all your applications to share data in real time.

September Events 2022

Check out all of these events

Attend in person or online, there are incredible conferences and events happening all throughout the month of September.

Users online (1,795)