cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
chrisingham
Helper I
Helper I

Using an expression for filepath in Onedrive

Hello,

 

I'm trying to use Flow to delete a file in a folder, based on the contents of a spreadsheet. 

 

The spreadsheet has a column called filename and the file is always in the same folder, but my flow always fails when attempting to delete the file. 

 

  1. Flow reads the spreadsheet
  2. I then use the following expression in a Compose section to define the file path of the file to be deleted which refers to the attachment name.
  3. concat('/Presales Triage Store/MPS/',string(items('Apply_to_each')?['Attachment Name']))
  4. The flow should delete the file at the path above. 

The output of the filepath is correct and says '/Presales Triage Store/MPS/automation test.docx' but I get the following error from MS Flow when trying to delete the file;

 

InvalidTemplate. Unable to process template language expressions in action 'Delete_file' inputs at line '1' and column '2687': 'The template language expression 'json(decodeBase64(triggerOutputs().headers['X-MS-APIM-Tokens']))['$connections']['shared_onedriveforbusiness']['connectionId']' cannot be evaluated because property 'shared_onedriveforbusiness' doesn't exist, available properties are 'shared_excelonlinebusiness, shared_office365'. Please see https://aka.ms/logicexpressions for usage details.'.

 

If I manually find the file using the explorer Flow will delete the file, but when using the above expression it fails. Does anyone know how to fix this?

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
v-alzhan-msft
Community Support
Community Support

Hi @chrisingham ,

 

Could you please share a screenshot of the configuration of your flow?

If you want to delete a file with Delete file action of OneDrive connector, you could only delete the file with the file identifier, we couldn't delete the file with file path with the action currently.

 

Best regards,

Alice       

 

Community Support Team _ Alice Zhang
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-alzhan-msft
Community Support
Community Support

Hi @chrisingham ,

 

Could you please share a screenshot of the configuration of your flow?

If you want to delete a file with Delete file action of OneDrive connector, you could only delete the file with the file identifier, we couldn't delete the file with file path with the action currently.

 

Best regards,

Alice       

 

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

chrisingham
Helper I
Helper I

Ah ok, I was hoping to use a dynamic file location using an expression. 

 

Maybe you can help find an easier solution to what I want to do. I currently have an automated flow running each time an email arrives, as part of that flow I want to 'hold' the attachment of that email along with a variable. Then, I want to create a second flow that runs at a scheduled time once per week to send out one email which contains all the attachments received in the last week along with a table in the email body with the variable from the earlier flow. 

 

I was trying to use a Onedrive folder as a 'cache' to save the attachments when the automated flow runs, and write the variable to a spreadsheet. Then once a week the scheduled flow can then read the items in the spreadsheet, attach the files to the email and send out. Then the flow will use the variables in the spreadsheet to delete the temporary files in the 'cache' folder and delete the records in the spreadsheet to reset the system so next week only the attachment received in the last week are sent out. 


Everything works apart from using the filename from the spreadsheet to delete the attachments from the folder to reset the system. Is there a better place I can temporarily save the files that I can then delete using flow and a spreadsheet? Or is there a better way to do this altogether?

 

Thanks

Hi @chrisingham ,

 

Please create a new post so your problem would be quickly replyed.

 

Best regards,

Alice       

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

Helpful resources

Announcements
MPA_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

V3_PVA CAmpaign Carousel.png

Community Challenge - Giveaways!

Participate in the Power Virtual Agents Community Challenge

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

PowerPlatform 768x460.png

Microsoft Learn

Check out our new Discover Your Career Path blog post series and get all the details.

Top Solution Authors
Users online (1,512)