web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id : bHDBKQ2EwzBEidmr1o+yBX
Power Automate - Building Flows
Answered

Using an expression for filepath in Onedrive

Like (0) ShareShare
ReportReport
Posted on 10 Jan 2020 15:56:08 by 32

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?

 

 

I have the same question (0)
  • v-alzhan-msft Profile Picture
    on 20 Jan 2020 at 09:26:30
    Re: Using an expression for filepath in Onedrive

    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.

  • chrisingham Profile Picture
    32 on 13 Jan 2020 at 12:35:57
    Re: Using an expression for filepath in Onedrive

    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

  • Verified answer
    v-alzhan-msft Profile Picture
    on 13 Jan 2020 at 03:09:37
    Re: Using an expression for filepath in Onedrive

    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.

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Tom Macfarlan – Community Spotlight

We are honored to recognize Tom Macfarlan as our Community Spotlight for October…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 707 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 499 Moderator

#3
chiaraalina Profile Picture

chiaraalina 312

Last 30 days Overall leaderboard
Loading complete