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

Check File Name Flow

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?

13 REPLIES 13
Super User
Super User

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

If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

Scott
MeToo_
Level: Powered On

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?

Community Support Team
Community Support Team

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

 

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.
MeToo_
Level: Powered On

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?

Community Support Team
Community Support Team

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

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.
MeToo_
Level: Powered On

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

Community Support Team
Community Support Team

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

 

 

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.
Administrator
Administrator

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

-Gabriel
Microsoft Flow Community Manager
MeToo_
Level: Powered On

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_
Level: Powered On

Re: Check File Name Flow

screenshot.png

Community Support Team
Community Support Team

Re: Check File Name Flow

Hi @MeToo_,

 

Please make sure that the condition is filled in the Excel Table column. It seems that you are filling in the value, and the value output is an array, so there will be an error that the type does not match.

screenshot.png

Please take a try.

 

Best Regards,

Barry

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.
MeToo_
Level: Powered On

Re: Check File Name Flow

What should my Excel File look like. Does this look right?

 

Table1    
Acme    
ADP    
United    
     
     
     
     
     
     
     
     
     
     
MeToo_
Level: Powered On

Re: Check File Name Flow

I finally got this working - instead of contains Value I used conatains Table1 and it fired off right away.

 

But now I have another issue. It runs the flow once per row in the table. I want it to run once per file. If it runs once per row row 1 will be true but the rest will be false becuase there will only be one row match per file. Its practically stating all the vales need to be true rather than process as true if one of the values is true. I want it to prcess per file rather than per row in the table.

Helpful resources

Announcements
firstImage

Microsoft Business Applications Virtual Launch Event

Watch the event on demand for an in-depth look at the new innovations across Dynamics 365 and the Microsoft Power Platform.

firstImage

Watch Sessions On Demand!

Continue your learning in our online communities.

Power Platform 2019 Release Wave 2 Plan

Power Platform 2019 Release Wave 2 Plan

Features releasing from October 2019 through March 2020.

thirdimage

Flow Community User Group Member Badge

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

fifthimage

Microsoft Learn

Learn how to build the business apps that you need.

sixthImage

Power Platform World Tour

Find out where you can attend!

seventhimage

Webinars & Video Gallery

Watch & learn from the Flow Community Video Gallery!

Top Kudoed Authors
Users Online
Currently online: 76 members 4,176 guests
Please welcome our newest community members: