cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Advocate II
Advocate II

Trigger Conditions - On file type in Sharepoint Document library

Hello,

 

Has anyone been able to successfully write a flow that uses a trigger condition on a sharepoint document library that only triggers when a specific file type is uploaded (.docx in this example)?

 

I am having a hard time getting a sharepoint document library to trigger only on docx files. Long story short, I am using the flow to convert docx files to pdf. The flow is looping back a 2nd time when the pdf file is created. If i can get the trigger condition to work, it will save me a 2nd flow run.

 

The main issue is getting the file type, file extension recognized. How can I write the trigger condition expression to do what I need? The other otpion is to extract the file name extension in sharepoint into another column as text. Then modify my trigger condition to look at that new column.

 

Capture.JPG

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Dual Super User
Dual Super User

Re: Trigger Conditions - On file type in Sharepoint Document library

Hi @JasonK 

 

Use following trigger condition for when an item is created or updated

 

@contains(triggerBody()?['{FilenameWithExtension}'],'.docx')

 

Regards,

Reza Dorrani

 

Regards,

Reza Dorrani

 

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

5 REPLIES 5
Highlighted
Dual Super User
Dual Super User

Re: Trigger Conditions - On file type in Sharepoint Document library

Hi @JasonK 

 

Use following trigger condition for when an item is created or updated

 

@contains(triggerBody()?['{FilenameWithExtension}'],'.docx')

 

Regards,

Reza Dorrani

 

Regards,

Reza Dorrani

 

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

Highlighted
Community Support
Community Support

Re: Trigger Conditions - On file type in Sharepoint Document library

Hi @JasonK ,

 

Please use the trigger "When a file is created or modified (properties only)" in the flow:

1.png

 

And use the expression below in the trigger Condition:

@contains(triggerBody()?['{FilenameWithExtension}'],'.docx')

Best regards,

Alice       

 

Community Support Team _ Alice Zhang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Highlighted
Advocate II
Advocate II

Re: Trigger Conditions - On file type in Sharepoint Document library

Awesome, Thank you for the info. Worked as stated.

 

Does anyone have any training resources on how to write Trigger conditions or better understand the structure?

Highlighted
Regular Visitor

Re: Trigger Conditions - On file type in Sharepoint Document library

The following worked for me for running on PDF documents only with the 'When a file is created or modified in a folder' Trigger:

 

@equals(triggerOutputs()['headers']['Content-Type'],'application/pdf')

 

 

Kind Regards,

Highlighted
New Member

Re: Trigger Conditions - On file type in Sharepoint Document library

Hi @RezaDorrani , 

 

I tried using this trigger for my flow:   @contains(triggerBody()?['{FilenameWithExtension}'],'.jpg')

 

but got the trigger error message below. It did not even run when I tested it.

 

InvalidTemplate. Unable to process template language expressions for trigger 'When_a_file_is_created_in_a_folder' at line '1' and column '5997': 'The template language function 'contains' expects its first argument 'collection' to be a dictionary (object), an array or a string. The provided value is of type 'Null'.'.
 
Thanks,

Helpful resources

Announcements
firstImage

Now Live: Power Virtual Agents Community!

We are excited to announce the launch of Power Virtual Agents Community. Check it out now!

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!

Top Solution Authors
Users online (7,999)