cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
New Member

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
Highlighted
Community Support
Community Support

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
Highlighted
Community Support
Community Support

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

Highlighted
New Member

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!

Highlighted
New Member

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?

Helper I
Helper I

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
secondImage

August 2020 CYST Winners!

Check out the winners of the recent 'Can You Solve These?' community challenge!

thirdImage

Experience what's new for Power Automate

Join us for an in-depth look at the new Power Automate features and capabilities at the free Microsoft Business Applications Launch Event.

firstImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

thirdimage

Power Automate Community User Group Member Badge

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

Top Solution Authors
Top Kudoed Authors
Users online (3,670)