cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
slvedva
Helper III
Helper III

Notification in Teams channel, when excel file is created and filled more then 1 line

Hi,

 

Maybe someone can help with Power Automate solution? I have MS Team channel, under files I create and store the excel standard report.

Is it possible create power automate automatic flow, where when system see, that file is created and excel report contain at least 2 rows, then system generate Teams notification in post area, that all channel users can get this notification - that system created the report X.

Reason about this "report contain at least 2 rows", because sometimes report can be empty, that mean in excel I have only report headers, in this case I don't need any Teams notification in post areas. Thanks in advance!

1 ACCEPTED SOLUTION

Accepted Solutions

Hi @slvedva ,

 

I'm happy to know that you found the error in the 'Run script' action! About the hyperlink, we can edit the Teams message as HTML to achieve it. 

 

First, go to the top right corner of your flow edit screen and disable the "New designer" mode. Some functionalities, like the HTML editor for Teams actions, are not available in this new designer:

rzaneti_0-1705668995418.png

 

Go to your 'Post message in a chat or channel' action, and you will notice that your action will have this HTML format (if you don't have a HTML format, click in the "</>" button, as highlighted in yellow):

rzaneti_1-1705669123546.png

 

Now we just need to assign the link to the file as a reference path. You can do it by adding <a href=" before the link dynamic content, and "> Link to the file</a> after it. You can change the text in red for something more meaningful according to your context.

 

After this change, your action will look like this:

rzaneti_2-1705669317583.png

 

And here is a comparison in Teams about how both cases would look like: the first doesn't have the link reference, and the second contains this HTML modification from the above instructions, with a hyperlink named "Link to the file":

rzaneti_3-1705669455841.png

 

 

Let me know if it works for you or if you need any additional help!

 

-------------------------------------------------------------------------
If this is the answer for your question, please mark the post as Solved.
If this answer helps you in any way, please give it a like.

http://digitalmill.net/ 
https://www.linkedin.com/in/raphael-haus-zaneti/ 

View solution in original post

19 REPLIES 19
rzaneti
Super User
Super User

Hi @slvedva ,

 

Are these reports formatted as table? If not, you must need an Office Script to read the file and identify if some specific ranges are empty or not.

 

For the later scenario, I will be happy in helping you to create this Office Script. I will just need a sample from your report file (make sure to fill it with fake data and remove any sensitive data before sharing it).

 

I'm also sharing a starter level article that I wrote some months ago about how to use the Office Scripts: http://digitalmill.net/2023/06/19/get-started-with-office-scripts/ and another post about how to access specific Excel ranges from Power Automate by using Office Scripts: http://digitalmill.net/2023/09/01/accessing-excel-ranges-with-power-automate/

slvedva
Helper III
Helper III

@rzaneti Attached I put empty table, but header always will be the same.

slvedva
Helper III
Helper III

@rzaneti I don't need take data from excel and post in teams, I just need post in Teams, that new file created and the file name, that all members from this channel receive notification.

Hi @slvedva ,

 

Thank you for sharing it! Even without including data from inside the file into the Teams message, you will still need the flow to access it to identify if the row 2 is empty or not. Here are some steps to get this flow working.

 

Step 1 - Setup the Office Script

We first need an Office Script to identify if the 2nd row of the Excel file is empty or not. In Excel (you don't need to have your report file opened), click in 'Automation' tab (highlighted in yellow) and then in 'New Script' (highlighted in green):

rzaneti_0-1705407566218.png

 

Then the 'Code editor' pane will appear in the right side of the screen (highlighted in yellow). Assign a name to the Script (highlighted in green):

rzaneti_1-1705408121386.png

 

 

And then paste the code  below into the editor:

function main(workbook: ExcelScript.Workbook) {
    let selectedSheet = workbook.getActiveWorksheet(); //Get worksheet
    let range = selectedSheet.getRange("A2:Q2") //Get range from Row 2 (A2:Q2)
    const rangeArr = range.getValues()[0] //Get values from the range above
    
    let isEmpty = true //Set true as default value for a variable to check if the Row 2 is empty

//Loop to test if each cell for Row 2 is empty or not. If any cell it's not empty, the variable 'isEmpty' will be changed to false.
    for (let i = 0; i < rangeArr.length; i++){ 
        if (rangeArr[i].length > 0){
            isEmpty = false
        }
    }

    return isEmpty //Return result from 'isEmpty' to Power Automate
}

 

Make sure to save the script.

 

Step 2 - Create a new flow in Power Automate

Start a new automated cloud flow by selecting the 'When a file is created (properties only)' trigger and select the folder where the new reports will be stored. In my case, I took the OneDrive version of this trigger, but feel free to pick the SharePoint one: 

rzaneti_2-1705408557920.png

 

Step 3 - Run the script for the new file

Now add a 'Run script' action, from Excel connector. In there, you will need to populate the details about your OneDrive or SharePoint path to the file. When selecting the 'File', add the document id as dynamic content (highlighted in green). In Script, select the just created Office Script (highlighted in yellow):

rzaneti_3-1705408834007.png

 

 

Step 4 - Testing if the file has the row 2 empty:

Now it's time to take the outputs from 'Run script' and test if the file contains an empty row 2 or not. To achieve it, add a 'Condition', set the 'result' dynamic content from 'Run script' in the left side (highlighted in yellow), keep the dropdown as 'is equal to' (highlighted in green) and insert 'false' (without quotes) in the right side (highlighted in blue):

rzaneti_4-1705409133934.png

rzaneti_5-1705409212823.png

 

 

Step 5 - Add your Teams action:

Inside the 'If yes' block of the condition, insert your Teams action. In my case, I'm inserting posting the message in a chat, but you can just make the 'Post In' option for channel. To inset the file name into the message, you just need to add the 'Name' property from the trigger as dynamic content:

rzaneti_7-1705409462691.png

 

Testing the flow

I've just added this file (just named as 'Book.xlsx') to the folder, and it contains a value in one of the cells of row 2:

rzaneti_8-1705409566679.png

 

The flow ran successfully:

rzaneti_9-1705409600210.png

 

And I've received the Teams message containing the file name (highlighted in green)

rzaneti_10-1705409634923.png

 

I've also added another file, but at this time without any value in row 2. The flow ran as expected, but didn't send any message in Teams:

rzaneti_11-1705409742978.png

 

If you need any change in this flow, let me know and I will be happy in helping you 🙂

 

Further reading

For those who are checking this response and are new to Power Automate, here are some articles related to the topics discussed in the solution:

- VBA vs. Office Scripts: http://digitalmill.net/2023/06/10/office-scripts-the-new-vba/ 

- Types of flows in Power Automate: http://digitalmill.net/2023/12/04/choosing-the-right-flow-type-in-power-automate/ 

- Conditions in Power Automate: http://digitalmill.net/2023/06/23/using-conditions-ifs-in-power-automate/ 

- Working with dynamic contents: http://digitalmill.net/2023/07/31/using-dynamic-content-in-power-automate/ 

 

Let me know if it works for you or if you need any additional help!

 

-------------------------------------------------------------------------
If this is the answer for your question, please mark the post as Solved.
If this answer helps you in any way, please give it a like.

http://digitalmill.net/ 
https://www.linkedin.com/in/raphael-haus-zaneti/ 

 

Hi @rzaneti 

I will check deeper and will try create my flow. But quick question, how to mark in this step - post message in channel, that this post will put up in this feed panel for channel users?

Hi @slvedva ,

 

You just need to change the "Post in" dropdown to "Channel". After that, you will see the input fields for "Team" and "Channel":

rzaneti_0-1705495654378.png

 

 

 

@rzaneti I mean, when post created, this channel changed to bold, that user will know, that some new message posted? 

slvedva_0-1705514949712.png

 

Hi @rzaneti 

I set-up my flow by your instructions and stuck with excel script, I take xlsx file from Sharepoint site, but don't understand why excel script something don't understand:

 

slvedva_0-1705577948083.png

 

slvedva
Helper III
Helper III

@rzaneti additional question - is it possible to add in this teams post message the link to the created file, not only the file name?

rzaneti
Super User
Super User

Hi @slvedva ,

 

Channel notification

When you post a new message to the channel via Power Automate, the channel will be bold, so the user will know that there is a new message:

 

rzaneti_0-1705583773757.png

 

The user will only be notified by Teams if they allow the notifications for the channel:

rzaneti_2-1705584031104.png

 

 

The notification will look like this:

rzaneti_1-1705584001933.png

 

Error with "Run Script"

Could you please share the raw outputs from your trigger? To find it, go to the flow run, expand the trigger and click in "Show raw outputs":

rzaneti_3-1705584141797.png

 

After that, share an image from the "body" of the JSON displayed on the right side of the screen (make sure to remove any sensitive data before sharing it, but ensure to leave the "DisplayName" extension visible). For more details about how to access the raw outputs, refer to this step-by-step: http://digitalmill.net/2023/06/29/how-to-access-the-raw-outputs-in-power-automate/

 

File link

It is possible to share a link with the user. First, add an action to generate a share link (you can do it either for SharePoint or OneDrive), passing the file id as input:

rzaneti_4-1705584366764.png

 

 

After that, in your 'Post message in a chat or channel' action, add the link as dynamic content, just like you did for the file name:

rzaneti_5-1705584418994.png

 

 

1. Here is body:

slvedva_0-1705585231222.png

2. Regarding file link, I put the link in post, but in post I get text row without hyperlink 😞

 

Hi @slvedva ,

 

We need the outputs from the trigger (When a file is created); you sent from the 'Run script' action. It looks like there is a problem in your trigger that is causing trouble to both the script and the link.

slvedva
Helper III
Helper III

Hi @rzaneti 

Here is output from triger:

slvedva_0-1705645659417.pngslvedva_1-1705645804216.png

 

@rzaneti I found the reason, when run this excel script, I wrongly put the link to file. Now it's work!

Still one small problem, I put in post the shared link, but in post I just see long text row without hyperlink 😞

Hi @slvedva ,

 

I'm happy to know that you found the error in the 'Run script' action! About the hyperlink, we can edit the Teams message as HTML to achieve it. 

 

First, go to the top right corner of your flow edit screen and disable the "New designer" mode. Some functionalities, like the HTML editor for Teams actions, are not available in this new designer:

rzaneti_0-1705668995418.png

 

Go to your 'Post message in a chat or channel' action, and you will notice that your action will have this HTML format (if you don't have a HTML format, click in the "</>" button, as highlighted in yellow):

rzaneti_1-1705669123546.png

 

Now we just need to assign the link to the file as a reference path. You can do it by adding <a href=" before the link dynamic content, and "> Link to the file</a> after it. You can change the text in red for something more meaningful according to your context.

 

After this change, your action will look like this:

rzaneti_2-1705669317583.png

 

And here is a comparison in Teams about how both cases would look like: the first doesn't have the link reference, and the second contains this HTML modification from the above instructions, with a hyperlink named "Link to the file":

rzaneti_3-1705669455841.png

 

 

Let me know if it works for you or if you need any additional help!

 

-------------------------------------------------------------------------
If this is the answer for your question, please mark the post as Solved.
If this answer helps you in any way, please give it a like.

http://digitalmill.net/ 
https://www.linkedin.com/in/raphael-haus-zaneti/ 

Hi @rzaneti 

Strange, I set like this:

slvedva_0-1705855691607.png

And here is result, there are no any link and not clear why 😞

slvedva_1-1705855761966.png

 

Hi @slvedva ,

 

Two small fixes: 

  1. After you <a href=...>, you need to close the tag by just adding </a> 
  2. Allocate "Link to file" text between the <a href=...> and the </a>

 

Let me know if it works!

slvedva
Helper III
Helper III

Hi @rzaneti 

I see, that you using post method Flow bot, in this case recipient you put teams channel email? Why for me it's don't work?

Hi @slvedva ,

 

You can just change the 'Post in' dropdown and select channel. Then you will be able to choose in which team and channel you want to post it in. 

Helpful resources

Announcements

Celebrating the May Super User of the Month: Laurens Martens

  @LaurensM  is an exceptional contributor to the Power Platform Community. Super Users like Laurens inspire others through their example, encouragement, and active participation. We are excited to celebrated Laurens as our Super User of the Month for May 2024.   Consistent Engagement:  He consistently engages with the community by answering forum questions, sharing insights, and providing solutions. Laurens dedication helps other users find answers and overcome challenges.   Community Expertise: As a Super User, Laurens plays a crucial role in maintaining a knowledge sharing environment. Always ensuring a positive experience for everyone.   Leadership: He shares valuable insights on community growth, engagement, and future trends. Their contributions help shape the Power Platform Community.   Congratulations, Laurens Martens, for your outstanding work! Keep inspiring others and making a difference in the community!   Keep up the fantastic work!        

Check out the Copilot Studio Cookbook today!

We are excited to announce our new Copilot Cookbook Gallery in the Copilot Studio Community. We can't wait for you to share your expertise and your experience!    Join us for an amazing opportunity where you'll be one of the first to contribute to the Copilot Cookbook—your ultimate guide to mastering Microsoft Copilot. Whether you're seeking inspiration or grappling with a challenge while crafting apps, you probably already know that Copilot Cookbook is your reliable assistant, offering a wealth of tips and tricks at your fingertips--and we want you to add your expertise. What can you "cook" up?   Click this link to get started: https://aka.ms/CS_Copilot_Cookbook_Gallery   Don't miss out on this exclusive opportunity to be one of the first in the Community to share your app creation journey with Copilot. We'll be announcing a Cookbook Challenge very soon and want to make sure you one of the first "cooks" in the kitchen.   Don't miss your moment--start submitting in the Copilot Cookbook Gallery today!     Thank you,  Engagement Team

Announcing Power Apps Copilot Cookbook Gallery

We are excited to share that the all-new Copilot Cookbook Gallery for Power Apps is now available in the Power Apps Community, full of tips and tricks on how to best use Microsoft Copilot as you develop and create in Power Apps. The new Copilot Cookbook is your go-to resource when you need inspiration--or when you're stuck--and aren't sure how to best partner with Copilot while creating apps.   Whether you're looking for the best prompts or just want to know about responsible AI use, visit Copilot Cookbook for regular updates you can rely on--while also serving up some of your greatest tips and tricks for the Community. Check Out the new Copilot Cookbook for Power Apps today: Copilot Cookbook - Power Platform Community.  We can't wait to see what you "cook" up!    

Welcome to the Power Automate Community

You are now a part of a fast-growing vibrant group of peers and industry experts who are here to network, share knowledge, and even have a little fun.   Now that you are a member, you can enjoy the following resources:   Welcome to the Community   News & Announcements: The is your place to get all the latest news around community events and announcements. This is where we share with the community what is going on and how to participate.  Be sure to subscribe to this board and not miss an announcement.   Get Help with Power Automate Forums: If you're looking for support with any part of Power Automate, our forums are the place to go. From General Power Automate forums to Using Connectors, Building Flows and Using Flows.  You will find thousands of technical professionals, and Super Users with years of experience who are ready and eager to answer your questions. You now have the ability to post, reply and give "kudos" on the Power Automate community forums. Make sure you conduct a quick search before creating a new post because your question may have already been asked and answered. Galleries: The galleries are full of content and can assist you with information on creating a flow in our Webinars and Video Gallery, and the ability to share the flows you have created in the Power Automate Cookbook.  Stay connected with the Community Connections & How-To Videos from the Microsoft Community Team. Check out the awesome content being shared there today.   Power Automate Community Blog: Over the years, more than 700 Power Automate Community Blog articles have been written and published by our thriving community. Our community members have learned some excellent tips and have keen insights on the future of process automation. In the Power Automate Community Blog, you can read the latest Power Automate-related posts from our community blog authors around the world. Let us know if you'd like to become an author and contribute your own writing — everything Power Automate-related is welcome.   Community Support: Check out and learn more about Using the Community for tips & tricks. Let us know in the Community Feedback  board if you have any questions or comments about your community experience. Again, we are so excited to welcome you to the Microsoft Power Automate community family. Whether you are brand new to the world of process automation or you are a seasoned Power Automate veteran - our goal is to shape the community to be your 'go to' for support, networking, education, inspiration and encouragement as we enjoy this adventure together.     Power Automate Community Team

Hear what's next for the Power Up Program

Hear from Principal Program Manager, Dimpi Gandhi, to discover the latest enhancements to the Microsoft #PowerUpProgram, including a new accelerated video-based curriculum crafted with the expertise of Microsoft MVPs, Rory Neary and Charlie Phipps-Bennett. If you’d like to hear what’s coming next, click the link below to sign up today! https://aka.ms/PowerUp  

Tuesday Tip | How to Report Spam in Our Community

It's time for another TUESDAY TIPS, your weekly connection with the most insightful tips and tricks that empower both newcomers and veterans in the Power Platform Community! Every Tuesday, we bring you a curated selection of the finest advice, distilled from the resources and tools in the Community. Whether you’re a seasoned member or just getting started, Tuesday Tips are the perfect compass guiding you across the dynamic landscape of the Power Platform Community.   As our community family expands each week, we revisit our essential tools, tips, and tricks to ensure you’re well-versed in the community’s pulse. Keep an eye on the News & Announcements for your weekly Tuesday Tips—you never know what you may learn!   Today's Tip: How to Report Spam in Our Community We strive to maintain a professional and helpful community, and part of that effort involves keeping our platform free of spam. If you encounter a post that you believe is spam, please follow these steps to report it: Locate the Post: Find the post in question within the community.Kebab Menu: Click on the "Kebab" menu | 3 Dots, on the top right of the post.Report Inappropriate Content: Select "Report Inappropriate Content" from the menu.Submit Report: Fill out any necessary details on the form and submit your report.   Our community team will review the report and take appropriate action to ensure our community remains a valuable resource for everyone.   Thank you for helping us keep the community clean and useful!

Users online (3,317)