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

If file contains -> create file - condition fails // Sharepoint to OneDrive Business

Hello,

I created a short flow to copy files created on a sharepoint to my Biz One Drive. When adding a contion to copy only files with specific string in the file name, the condition always evaluates to false. 

I need only files which contain "Report" in the name to be moved. 

 

Also, I see when modifying the uploaded file on the sharepoint, the flow says "The file is currently checked out or locked for editing by another user. " and doesn't update the file version. 

 

I have changed the trigger step to "When a file is created or modified..." but get the below:

Request to Azure Resource Manager failed with error: '{"error":{"code":"WorkflowTriggerHistoryNotFound","message":"The workflow '32d842d3-507b-4f64-ac3f-6aa83da870ea' trigger 'When_a_file_is_created_or_modified_in_a_folder' history '08586457716245071125362579330CU99' could not be found."}}'.

 

Any ideas why all the fails ?

 

Thanks!

 

Flow.PNG

1 ACCEPTED SOLUTION

Accepted Solutions
v-zhos-msft
Level 10

Re: If file contains -> create file - condition fails // Sharepoint to OneDrive Business

Hi @Mihnea ,

The 'Get file content' need to be added before the 'Condition'.

Here the file content is from sharePoint library, so you need use the action 'Get file content (SharePoint)'.

Best Regards,

Community Support Team _ Zhongys

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

7 REPLIES 7
Super User
Super User

Re: If file contains -> create file - condition fails // Sharepoint to OneDrive Business

It may be worthwhile to review the official documentation for Flow conditions, the SharePoint Online Connector documention and a visual explanation of logical expressions

The problem with the When a file is created trigger, is that it only gives you a handful of operators to work with. Because of this, I almost always use the Get files (properties only) action to expand my list of options.

Spoiler
Get file does not work, because it needs an ID operator, which the When a file is created trigger doesn't offer.  

With that said, I think adding the Get Files (Properties Online) and using the Name string rather than the File name should resolve your issue, as seen below.

Spoiler
Get files adds a loop, so depending on the number of files in the document library, it will check each one of them every time a new file is created, so you may want to add an additional condition to only worry about files uploaded "today". The utcnow expression is how you'd achieve this (date/time formatting). 

Condition.PNG

 

 

v-zhos-msft
Level 10

Re: If file contains -> create file - condition fails // Sharepoint to OneDrive Business

Hi @Mihnea ,

I have made a test with the 'When a file is created in a folder' trigger.

However the file name will change to code in this trigger, so you 'Condition' will always false.

Capture3.PNG

I suggest you use the 'When a file is created (properties only)' trigger.

Capture2.PNG

Best Regards,

Community Support Team _ Zhongys

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Mihnea
Level: Powered On

Re: If file contains -> create file - condition fails // Sharepoint to OneDrive Business

Thanks for the suggestion but If I go for "When a file is created - Properties only" then it seems I can't opt for the "File content"  when I add the Create file action so is there any other way to retrieve that entire file ? 

 

Thank you!

v-zhos-msft
Level 10

Re: If file contains -> create file - condition fails // Sharepoint to OneDrive Business

Hi @Mihnea ,

You can add the 'Get file content' action in you flow to get the file content.

Capture.PNGCapture1.PNG

Best Regards,

Community Support Team _ Zhongys

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Mihnea
Level: Powered On

Re: If file contains -> create file - condition fails // Sharepoint to OneDrive Business

so the condition has to be entered after getting the content?

So if I want to save the content to onedrive, i need to Get file content (OneDrive for Business) before the condition? 

I never know when to use actions from which app group..

 

Thanks,

v-zhos-msft
Level 10

Re: If file contains -> create file - condition fails // Sharepoint to OneDrive Business

Hi @Mihnea ,

The 'Get file content' need to be added before the 'Condition'.

Here the file content is from sharePoint library, so you need use the action 'Get file content (SharePoint)'.

Best Regards,

Community Support Team _ Zhongys

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

Mihnea
Level: Powered On

Re: If file contains -> create file - condition fails // Sharepoint to OneDrive Business

So If I want to save that file to my PC ?

Helpful resources

Announcements
firstImage

Better Together Contest Finalists Announced!

Congrats to the finalists of our ‘Better Together’-themed T-shirt design contest! Click for the top entries.

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

Community Summit North America

The top training and networking event across the globe for Microsoft Business Applications

Top Solution Authors
Top Kudoed Authors
Users online (9,380)