cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Regular Visitor

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
Highlighted
Super User III
Super User III

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
Highlighted
Regular Visitor

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?

Highlighted
Community Support
Community Support

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.
Highlighted
Regular Visitor

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?

Highlighted
Community Support
Community Support

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.
Highlighted
Regular Visitor

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

Highlighted
Community Support
Community Support

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.
Highlighted
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
Community Manager
Power Automate | Power Virtual Agents
Super User Program Manager
Power Platform Communities
Highlighted
Regular Visitor

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""",
Highlighted
Regular Visitor

Re: Check File Name Flow

screenshot.png

Highlighted
Community Support
Community Support

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.
Highlighted
Regular Visitor

Re: Check File Name Flow

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

 

Table1    
Acme    
ADP    
United    
     
     
     
     
     
     
     
     
     
     
Highlighted
Regular Visitor

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
Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

Power Platform ISV Studio

Power Platform ISV Studio

ISV Studio is designed to become the go-to Power Platform destination for ISV’s to monitor & manage published applications.

Tech Marathon

Maratón de Soluciones de Negocio Microsoft

Una semana de contenido con +100 sesiones educativas, consultorios, +10 workshops Premium, Hackaton, EXPO, Networking Hall y mucho más!

Top Solution Authors
Top Kudoed Authors
Users online (6,028)