cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
konczera
Regular Visitor

Send a customized email when a new file is added - limit to extension name and file names

Dear all,

 

I have some issues with Power Automate.

 

When using Sharepoint, I would like to notify a recipient when a new file with a specific extension and file name is created.

For example, I want to send a mail to xy@mail.com that an Excel file with file name starting with "12345" has been saved on this link.

 

However, I cannot find any options for filtering for file extensions or file names in my flow.

 

image.png

 

Can anybody help me please if such filtering is possible?

 

Thank you in advance

7 REPLIES 7
DPozzi
Helper II
Helper II

I'm not an expert but may I ask which trigger you use? if it's the creation or modification of an item in a sharepoint document library, maybe you could create a variable with the extension trimming the filename of the created file then you could use a conditional check

konczera
Regular Visitor

It's a creation of an item. I am quite a beginner in Power Automate, could you please show how to execute your advise?

Thanks in advance

DPozzi
Helper II
Helper II

I'm not a pro too but I'll try to help, so the trigger must be "when a file is created  in a folder"

DPozzi_0-1664293268503.png

then let's init a variable spliting the file identifier from the trigger: split(triggerOutputs()?['headers/x-ms-file-id'], '.')

DPozzi_0-1664299525486.png

DPozzi_4-1664300060144.png

 

then init the Extension variable

DPozzi_1-1664299637220.png

variables('FileIdentifier')[1]
 
the variables()[index] will extract the value from the array in that case the part after the "." 
I'm not considering that the filename could have other "." other than one before the extension but it's just to give you an idea.
 
DPozzi_2-1664299899423.png

 

alternative/in addition with "GET FILE METADATA" using the same file identifier from the trigger you can get other info, like the filename or the media type

DPozzi_3-1664299962251.png

 

Then you can use conditional control to perform specific action if it's an image, doc, xlsx etc etc.

I hope that this will help you ^_^

konczera
Regular Visitor

Hello,

thanks for the help.

 

When testing the flow, I got this error message for Initialize variable 2:

"Unable to process template language expressions in action 'Initialize_variable_2' inputs at line '0' and column '0': 'The template language function 'split' expects its first parameter to be of type string. The provided value is of type 'Null'. Please see https://aka.ms/logicexpressions#split for usage details.'."

 

I suppose I have to adjust something in this command?

 

konczera_1-1664438368982.png

split(triggerOutputs()?['headers/x-ms-file-id'], '.')

Your trigger is different than mine

DPozzi_0-1664442370803.png

 

it's not a problem but you can't copy paste my previous command, with this trigger it will change as:

 

split(triggerOutputs()?['body/{Identifier}'], '.')

 

due the trigger answers with a different set of properties

 

konczera
Regular Visitor

Thank you a lot, it worked!

 

Do you know if there is an option to limit the automated e-mail sending to a special file names only? For instance, there are many files created on a link, but I only want to send notification if an excel file containing the name "12345" is created.

 

Thanks in advance.

DPozzi
Helper II
Helper II

I'm glad it worked, about the mail you should add a conditional step before the mail sending phase, with two conditions, extension eq xlsx AND filename contains "12345"

Helpful resources

Announcements
Microsoft 365 Conference – December 6-8, 2022

Microsoft 365 Conference – December 6-8, 2022

Join us in Las Vegas to experience community, incredible learning opportunities, and connections that will help grow skills, know-how, and more.

Users online (3,681)