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 :
Power Automate - Building Flows
Unanswered

Check File Name Flow

(0) ShareShare
ReportReport
Posted on by 31

I am trying to add a condition to a Flow that will decide yes or no according to words in the file name. My condition looks like this but keeps failing

 

@contains(triggerOutputs()['headers']['x-ms-file-name-encoded'], 'Acme')

 

How do I fix this and what do I do if I want to look for more than one word in the file name?

I have the same question (0)
  • ScottShearer Profile Picture
    25,254 Most Valuable Professional on at
    Re: Check File Name Flow

    Can you explain what you mean by failing?  Do you see an error or does it not work as expected?

     

    Scott

  • MeToo_ Profile Picture
    31 on at
    Re: Check File Name Flow

    Yes, I get an error:

     

    The request failed. Error code: '404'. Error Message: 'The response is not in a JSON format.'.

     

    How do I place this in proper JSON format?

  • v-bacao-msft Profile Picture
    on at
    Re: Check File Name Flow

    Hi @MeToo_,

     

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

     

    I have made a test on my side and don't have the issue that you mentioned.

     

    19.PNG

    But this design can not check whether the filename contains the specified value, because "triggerOutputs()['headers']['x-ms-file-name-encoded']" outputs some special encoding values, not the name of the file display.

    18.PNG

    You could use Get File metadata to get the Display Name of the file to judge. Then use Expression to check if one or more specified values are included.

     

    Expression reference:

    @and(contains(body('Get_file_metadata')?['DisplayName'], 'Acme'), contains(body('Get_file_metadata')?['DisplayName'], 'Test'))

    22.PNG

    It worked, as below:

    21.PNG

    Please take a try and let me know if issue still exist.

     

    Best Regards,

    Barry

     

  • MeToo_ Profile Picture
    31 on at
    Re: Check File Name Flow

    This worked!

     

    I have one more question. What would be the best way of addressing a list of values. Let's say I want to check for 10 different words in the file name and act accordingly. How would this be best addressed?

  • v-bacao-msft Profile Picture
    on at
    Re: Check File Name Flow

    Hi @MeToo_,

     

    Do you mean that if you want to check a lot of words, the expression will be complicated?

     

    I need to know that you want to check that the file name contains only one word, the condition is met, or all words are included.

     

    If it is Or, you could try the following workaround:

     

    Create a new table, enter the word you want to check. Because it is an Or relationship, execute the next step as long as one meets the condition. There is no action in If No.

     

    Image reference:

     

    28.PNG

    27.PNG

     

    Please take a try.

     

    Regards,

    Barry

  • MeToo_ Profile Picture
    31 on at
    Re: Check File Name Flow

    I have tried this and get the following error:

    InvalidTemplate. Unable to process template language expressions for action 'Condition' at line '1' and column '2432': 'The template language function 'contains' expects parameters of matching types: a dictionary and a key (string), an array and a value (object), or a string and a substring. The provided types 'String' and 'Array' are incompatible. Please see https://aka.ms/logicexpressions#contains for usage details.'.

     

    Did I do something wrong on the get row action? Seems like no data was extacted from the get rows action

  • v-bacao-msft Profile Picture
    on at
    Re: Check File Name Flow

    Hi @MeToo_,

    Could you provide your flow run details?

    Especially the output of the Get Rows action.

    I would be helpful if you posted a screen shot of the Flow as well.

     

    Best Regards,

    Barry

     

     

  • GabrielStJohn Profile Picture
    on at
    Re: Check File Name Flow

    Hey, @MeToo_!

     

    Thank you for posting on the Flow Community Forum! It appears as though @v-bacao-msft would like some more information in order to further assist you properly with your issue. Please share any additional information that was requested in order to decrease the amount of time that it will take for you to be assisted!

     

    Thank you for being an active member of the Flow Community!

     

    -Gabriel
    Flow Community Manager

  • MeToo_ Profile Picture
    31 on at
    Re: Check File Name Flow
    Inputs
    File name
    /AP Invoice Supplier Filter.xlsx
    Table name
    Table1
    Outputs
    Status code
    200
    Headers
    Pragma
    no-cache
    Vary
    Accept-Encoding
    x-ms-request-id
    6fe82ed9-5d78-4c24-94cb-9492f39c227a
    OData-Version
    4.0
    Strict-Transport-Security
    max-age=31536000
    X-Content-Type-Options
    nosniff
    X-Frame-Options
    DENY
    Timing-Allow-Origin
    *
    x-ms-apihub-cached-response
    false
    Cache-Control
    no-cache
    Date
    Sat, 22 Sep 2018 16:16:57 GMT
    X-AspNet-Version
    4.0.30319
    X-Powered-By
    ASP.NET
    Content-Type
    application/json; odata.metadata=minimal; odata.streaming=true
    Expires
    -1
    Content-Length
    520
    Body
    {
      "@odata.context""https://excel-eus.azconn-eus.p.azurewebsites.net/$metadata#datasets('01MZODM37V2BZON22YXNDZBFKSAKPJFKN6')/tables('Table1')/items",
      "value": [
        {
          "@odata.etag""",
  • MeToo_ Profile Picture
    31 on at
    Re: Check File Name Flow

    screenshot.png

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…

Chiara Carbone – Community Spotlight

We are honored to recognize Chiara Carbone as our Community Spotlight for November…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 659 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 386 Moderator

#3
chiaraalina Profile Picture

chiaraalina 290

Last 30 days Overall leaderboard