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!

Highlighted
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

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: 177 members 3,500 guests
Please welcome our newest community members: