cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
FJanssen1
Level: Power Up

Condition Filename 'Starts With' is not working for Copy File

First post to this forum.  I am not a programmer, but I have been creating flows for months now - but am stuck on what I would assume is a slam dunk easy one, I simply want to copy a new or modified file from one Sharepoint folder to Another if the filename begins with a certain string.  These are PDF files that are named for an Order Number that begins with something like '703' (i.e. 7031234567.pdf). 

 

Regardless of how I use the condition (Starts With, Contains, Equals) The flow runs successfully, but the results of the condition are False. I am using single quotes to ensure a 'string' comparison.  I've also tried Contains / Equals and have tried these other normal filenames to avoid the numeric issue (i.e. just naming the file 'INVOICE' - with or without the extension), - but always returns False. What Am I missing?

 

Trigger = Sharepoint - When a file is created or modified in a folder

Condition - File Name starts with (contains, equals) - '703' ('7031234567' / INVOICE / INVOICE.pdf )

 

@startsWith(triggerOutputs()['headers']['x-ms-file-name-encoded'], '703') ... have used all combinations of single/double/no quotes. 

 

Any help is appreciated

 

1 ACCEPTED SOLUTION

Accepted Solutions
Community Support Team
Community Support Team

Re: Condition Filename 'Starts With' is not working for Copy File

Hi @ FJanssen1,

 

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

Why are you use the expression "triggerOutputs()['headers']['x-ms-file-name-encoded']" in the condition of your flow?

 

I have made a test on my side to use expression "triggerBody()?['{FilenameWithExtension}']" in the condition of my flow and don't have the issue that you mentioned.

 

I have create a flow as screenshot below:

Capture.PNG

 

The expression in the condition as below:

@startsWith(triggerBody()?['{FilenameWithExtension}'], '703')

 

When a file is created or modified in the library, the flow would run successfully as below:

Capture.PNG

 

 

Please check the expression in the condition of your flow, and take a try to use "triggerBody()?['{FilenameWithExtension}']" instead of "triggerOutputs()['headers']['x-ms-file-name-encoded']" in your flow to see if the issue still exists.

 

 

Regards,
Alice Zhang

View solution in original post

4 REPLIES 4
Community Support Team
Community Support Team

Re: Condition Filename 'Starts With' is not working for Copy File

Hi @ FJanssen1,

 

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

Why are you use the expression "triggerOutputs()['headers']['x-ms-file-name-encoded']" in the condition of your flow?

 

I have made a test on my side to use expression "triggerBody()?['{FilenameWithExtension}']" in the condition of my flow and don't have the issue that you mentioned.

 

I have create a flow as screenshot below:

Capture.PNG

 

The expression in the condition as below:

@startsWith(triggerBody()?['{FilenameWithExtension}'], '703')

 

When a file is created or modified in the library, the flow would run successfully as below:

Capture.PNG

 

 

Please check the expression in the condition of your flow, and take a try to use "triggerBody()?['{FilenameWithExtension}']" instead of "triggerOutputs()['headers']['x-ms-file-name-encoded']" in your flow to see if the issue still exists.

 

 

Regards,
Alice Zhang

View solution in original post

FJanssen1
Level: Power Up

Re: Condition Filename 'Starts With' is not working for Copy File

Thank you. 

 

Changing from the SP Trigger: File Created or Modified  to the one you showed, File Created of Modified Properties Only)  and using your condition statement made the difference.  I don't really understand the difference between the triggers (after reading the help) - but I'll chalk that up to my general ignorance... I am just glad it works - Thank You!

A_Karolien
Level: Power Up

Re: Condition Filename 'Starts With' is not working for Copy File

Hi Alice,

 

I have a similar problem as Fjanssen1 but when I try to use "triggerBody()?['{FilenameWithExtension}']" instead of "triggerOutputs()['headers']['x-ms-file-name-encoded']" I get an error on my flow when running that says: 

"InvalidTemplate. Unable to process template language expressions for action 'Condition' at line '1' and column '2529': 'The template language expression 'startsWith(triggerBody()['{FilenameWithExtension}'], '"Active Users"')' cannot be evaluated because property '{FilenameWithExtension}' cannot be selected. Property selection is not supported on values of type 'String'. Please see https://aka.ms/logicexpressions for usage details.'.

 

Do you have any idea on how to cope with this error?

Mihnea
Level: Powered On

Re: Condition Filename 'Starts With' is not working for Copy File

Hello,

 

How do I get to see the Condition in that Advanced way so that I can enter "code" ? 

 

THanks,

Mihnea 

Helpful resources

Announcements
firstImage

Power Platform Online Conference

Join us for the first ever Power Platform Online Conference!

firstImage

Incoming: New and improved badges!

Look out for new contribution recognition badges coming SOON!

firstImage

New & Improved Power Automate Community Cookbook

We've updated and improved the layout and uploading format of the Power Automate Cookbook!

thirdimage

Power Automate Community User Group Member Badge

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

sixthImage

Power Platform World Tour

Find out where you can attend!

seventhimage

Webinars & Video Gallery

Watch & learn from the Power Automate Community Video Gallery!

Top Solution Authors
Top Kudoed Authors
Users online (5,032)