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

Reminder before the exp. date

Hello,

 

My sharepoint list is like below.

koray1_0-1669117196825.png

 

There are 2 things I want to do.

 

1-) SKT column means expiration date. I want it to send an e-mail 7 days before the expiration date.

 

2-) There are lot numbers for the material codes in the titer column. If the Total_Stock total in all lots of a material code is less than the number in Safety_Stock, send a notification mail.

 

I checked many topics in the forum, I tried, but unfortunately I could not. I will be grateful if you could help me.

 

Regards.

 

1 ACCEPTED SOLUTION

Accepted Solutions

That makes complete sense now 🙂

 

For this example, I'm using the following list:

grantjenkins_0-1669289589747.png

 

Full flow below. I'll go into each of the actions.

grantjenkins_1-1669289732202.png

 

When an item is created or modified will give us the item that was created or modified.

grantjenkins_2-1669289771427.png

 

Get items will return items in the list where the Title is equal to the Title of the item that was created or modified. Or more precisely, items that have the same Material code.

grantjenkins_3-1669289907608.png

 

XML is a Compose action. Rather than looping over each of the items and adding the totals, I'm going to use XPath which is much more efficient (no need for a loop). To use XPath, we need to convert our JSON to XML. The expression used is below, including adding a root element to ensure its valid XML.

xml(json(concat('{"root": ', outputs('Get_items')?['body'], '}')))

grantjenkins_4-1669290040262.png

 

Total Stock is a Compose action that uses XPath to calculate the sum of all the Total Stock of the current Material code items. The expression used is:

xpath(outputs('XML'), 'sum(//value/Total_Stock)')

grantjenkins_5-1669290117534.png

 

Safety Stock is a Compose action that gets the first Safety Stock value since they are duplicated across all our items. This assumes that there will always be a number entered in the Safety Stock column.

first(outputs('Get_items')?['body/value'])?['Safety_Stock']

grantjenkins_6-1669290637789.png

 

We then have a Condition to check if Total Stock is less than Safety Stock.

grantjenkins_7-1669290742292.png

 

If Total Stock is less than Safety Stock, we send an email.

grantjenkins_8-1669290789705.png

 

Hopefully that's what you're after.


----------------------------------------------------------------------
If I've answered your question, please mark the post as Solved.
If you like my response, please consider giving it a Thumbs Up.

View solution in original post

22 REPLIES 22
Sundeep_Malik
Multi Super User
Multi Super User

Hey @koray1 '

 

 

You will have to make two different flows for this:

 

1) For Expiration Date:

 

Run a Recurrence flow that runs daily once.

 

Keep the filter query of get items as:

 

Sundeep_Malik_3-1669122240716.png

 

 

Expression above: 

addDays(utcNow(),7,'dd.MM.yyyy')
Full filter query, you can just copy the below in your filter query:
SKT eq '@{addDays(utcNow(),7,'dd.MM.yyyy')}'
 
2) For 2nd flow do this:
 
Keep the get items filter query empty. Take a compose and store the the first value of Safety_Stock like this:
 
Sundeep_Malik_1-1669121932890.png

put the dynamic field of that column here. 

Though I am little worried in your picture above I can see some values are empty for that column. And you might have to convert it to an integer by writing: int(first(dynmicfield))

 

After this use a condition like this:

 

Sundeep_Malik_2-1669122079861.png

 

This will just check if the total number of rows in the list is less than safety stock, send a reminder.

 

I hope this will help. 🙂

 

If you liked the explanation, you can give a thumbs up and if this was the solution you required, you can accept this as the solution. 🙂

Hello @Sundeep_Malik 

 

Thanks a lot for your help.

I'm new about poweautomate. I guess that's why I couldn't. 
The flow is giving the following error and I don't know how to email these notifications to me.

koray1_0-1669199735448.png

 

Step 2 was again very difficult for me. Isn't there an easier way to do this?

Regards.

Sundeep_Malik
Multi Super User
Multi Super User

@koray1 

 

Can you show what you have written in get items for Flow 1 in the filter query?

 

For flow 2 cant think of a method currently.

 

Tagging some people, who might help.

 

@Pstork1 

@grantjenkins 

@v-liwei-msft 

@v-yujincui-msft 

@v-jefferni 

@v-chengfen-msft 

 

Hi @Sundeep_Malik 

 

koray1_1-1669205573906.png

 

addDays(utcNow(),7,'dd.MM.yyyy')
grantjenkins
Super User
Super User

@koray1 

 

For 1)

  1. Is your SKT column in SharePoint a DateTime field type, or Single line of text?

 

For 2)

  1. Did you want to check these totals once a day? Just wondering how often you would be sending that notification.
  2. Are you checking the total grouped by Material Code?
    1. If so, how would you want the email to be displayed if say there were 5 Material Codes that had Total Stock less than Safety Stock?

----------------------------------------------------------------------
If I've answered your question, please mark the post as Solved.
If you like my response, please consider giving it a Thumbs Up.

Hi @grantjenkins 

For1)

  1. Is your SKT column in SharePoint a DateTime field type, or Single line of text?

Yes. SKT column is Date and Time

koray1_0-1669207872072.png

For 2)

  1. Did you want to check these totals once a day? Just wondering how often you would be sending that notification.

- Time is not important. I want it to send an e-mail as soon as the Total_Stock column falls below the number written in Safety_Stock.

 

Are these grouped by lot number - for instance you would check the totals for 423538, the totals for 423534, etc.

- There is no grouping. There may be different lot numbers for each "titer". For example, there are 2 different lot numbers for 423538. The app does not give automatic sum of them. I don't know how to calculate them. But if it is difficult to calculate, we can proceed independently of the lot number.

 

And if they are grouped, what would the email look like if there were say 5 lots that had Total Stock less than Safety Stock?

 

- It should have been, safety stock 480 for 423538 in the list but your stock is 400. Check this out. I wish it was 🙂

 

@koray1 Can you do what @Sundeep_Malik mentioned about the formatDateTime, but set the format to 'yyyy-MM-dd' and see if that works.


----------------------------------------------------------------------
If I've answered your question, please mark the post as Solved.
If you like my response, please consider giving it a Thumbs Up.

@koray1 

 

For the Total Stock / Safety Stock we can definitely build what you're after (including totals), but just wanted to make sure I've got it right.

 

You mentioned that you wanted an email as soon as the total goes too low. I'm assuming you want to check the total every time you update an item - so the trigger would be something like when item created or modified.

 

Then say if you update the item with Lot Number 2069960 (which belongs in Titre 423538), you will want to get the sum of Total_Stock across all records with Titre 423538.

 

Then with Safety_Stock, is 480 the total for Titre, or Lot Number? I mean are we checking to see if the total of Total_Stock is less than 480 in this instance or less than 480 + 480?

 

 

On another note, Safety_Stock has a lot of empty fields. If empty, do we just default to 0? Or will there always be a number in there, but just not in your example?


----------------------------------------------------------------------
If I've answered your question, please mark the post as Solved.
If you like my response, please consider giving it a Thumbs Up.

Hi @grantjenkins 

Flow did not error now. But he needs to email me this process. How do we do this?

koray1_0-1669279567164.png

 

hi @grantjenkins 

Absolutely right. The trigger should run when a new titer and lot number are created or Total_Stock is changed.

I made a sample table below for calculation, I think it will be better understood.

 

koray1_1-1669280429503.png

 

Thank you for help!

Regard.

That makes complete sense now 🙂

 

For this example, I'm using the following list:

grantjenkins_0-1669289589747.png

 

Full flow below. I'll go into each of the actions.

grantjenkins_1-1669289732202.png

 

When an item is created or modified will give us the item that was created or modified.

grantjenkins_2-1669289771427.png

 

Get items will return items in the list where the Title is equal to the Title of the item that was created or modified. Or more precisely, items that have the same Material code.

grantjenkins_3-1669289907608.png

 

XML is a Compose action. Rather than looping over each of the items and adding the totals, I'm going to use XPath which is much more efficient (no need for a loop). To use XPath, we need to convert our JSON to XML. The expression used is below, including adding a root element to ensure its valid XML.

xml(json(concat('{"root": ', outputs('Get_items')?['body'], '}')))

grantjenkins_4-1669290040262.png

 

Total Stock is a Compose action that uses XPath to calculate the sum of all the Total Stock of the current Material code items. The expression used is:

xpath(outputs('XML'), 'sum(//value/Total_Stock)')

grantjenkins_5-1669290117534.png

 

Safety Stock is a Compose action that gets the first Safety Stock value since they are duplicated across all our items. This assumes that there will always be a number entered in the Safety Stock column.

first(outputs('Get_items')?['body/value'])?['Safety_Stock']

grantjenkins_6-1669290637789.png

 

We then have a Condition to check if Total Stock is less than Safety Stock.

grantjenkins_7-1669290742292.png

 

If Total Stock is less than Safety Stock, we send an email.

grantjenkins_8-1669290789705.png

 

Hopefully that's what you're after.


----------------------------------------------------------------------
If I've answered your question, please mark the post as Solved.
If you like my response, please consider giving it a Thumbs Up.

Hello @grantjenkins 
Thank you very much for your effort.
Where am I going wrong? 😞

koray1_0-1669293954663.png

 

koray1_1-1669294024953.png

koray1_2-1669294080730.png

 

grantjenkins
Super User
Super User

In your Filter Query on Get items you should be testing with Titre, not Product No.

 

And for Total Stock and Safety Stock you need to add those expressions as per the screenshot below (not just pasted into the input as text):

 

grantjenkins_0-1669295533481.png

 


----------------------------------------------------------------------
If I've answered your question, please mark the post as Solved.
If you like my response, please consider giving it a Thumbs Up.

It doesn't accept Titre so I changed as Title

 

koray1_0-1669296363712.png

 

 

New issue:

koray1_1-1669296433274.png

 

Are some of your Safety Total columns blank (don't have a number)?


----------------------------------------------------------------------
If I've answered your question, please mark the post as Solved.
If you like my response, please consider giving it a Thumbs Up.

Hi @grantjenkins 

Columns don't actually have blank lines. I also checked the column types. All of them are number type.

koray1_0-1669305160778.png

 

The Total_Stock row has numbers 0. Could it be related to that?

 

koray1_1-1669305511023.png

 

 

grantjenkins
Super User
Super User

Values of 0 wont' cause an error.

 

Are you able to check the internal column names for your Total Stock and Safety Stock and make sure those are the names you're using in your expressions?

 

Also, just to confirm, you updated both the expressions for Total Stock and Safety Stock (not just pasted the text)?


----------------------------------------------------------------------
If I've answered your question, please mark the post as Solved.
If you like my response, please consider giving it a Thumbs Up.

Hi @grantjenkins 

I've checked everywhere but it keeps giving the same error.

koray1_0-1669715005171.pngkoray1_1-1669715036022.pngkoray1_2-1669715118196.png

 

koray1_3-1669715169116.png

 

koray1_8-1669715677203.png

 

koray1_5-1669715312625.pngkoray1_6-1669715363868.pngkoray1_7-1669715606212.png

 

koray1_9-1669715867668.png

 

When I run a test for Flow, it calculates Total Stock and Safety Stock correctly.

 

Test for product no: 423538
Total stock is:  445 (400+45)

Safety stock is: 480

koray1_10-1669716071879.png

 

 

 

koray1_11-1669716112561.png

 

but it gives an error in the condition part 😞

 

koray1_12-1669716170386.png

koray1_13-1669716319806.png

 

 

 

 

grantjenkins
Super User
Super User

When you run the flow can you click on Show raw outputs for both Total Stock and Safety Stock to ensure they are both numbers (not enclosed within double quotes).

 

grantjenkins_0-1669720473145.png

 


----------------------------------------------------------------------
If I've answered your question, please mark the post as Solved.
If you like my response, please consider giving it a Thumbs Up.

Helpful resources

Announcements

Calling all User Group Leaders and Super Users! Mark Your Calendars for the next Community Ambassador Call on May 9th!

This month's Community Ambassador call is on May 9th at 9a & 3p PDT. Please keep an eye out in your private messages and Teams channels for your invitation. There are lots of exciting updates coming to the Community, and we have some exclusive opportunities to share with you! As always, we'll also review regular updates for User Groups, Super Users, and share general information about what's going on in the Community.     Be sure to register & we hope to see all of you there!

April 2024 Community Newsletter

We're pleased to share the April Community Newsletter, where we highlight the latest news, product releases, upcoming events, and the amazing work of our outstanding Community members.   If you're new to the Community, please make sure to follow the latest News & Announcements and check out the Community on LinkedIn as well! It's the best way to stay up-to-date with all the news from across Microsoft Power Platform and beyond.    COMMUNITY HIGHLIGHTS   Check out the most active community members of the last month! These hardworking members are posting regularly, answering questions, kudos, and providing top solutions in their communities. We are so thankful for each of you--keep up the great work! If you hope to see your name here next month, follow these awesome community members to see what they do!   Power AppsPower AutomateCopilot StudioPower PagesWarrenBelzDeenujialexander2523ragavanrajanLaurensMManishSolankiMattJimisonLucas001AmikcapuanodanilostephenrobertOliverRodriguestimlAndrewJManikandanSFubarmmbr1606VishnuReddy1997theMacResolutionsVishalJhaveriVictorIvanidzejsrandhawahagrua33ikExpiscornovusFGuerrero1PowerAddictgulshankhuranaANBExpiscornovusprathyooSpongYeNived_Nambiardeeksha15795apangelesGochixgrantjenkinsvasu24Mfon   LATEST NEWS   Business Applications Launch Event - On Demand In case you missed the Business Applications Launch Event, you can now catch up on all the announcements and watch the entire event on-demand inside Charles Lamanna's latest cloud blog.   This is your one stop shop for all the latest Copilot features across Power Platform and #Dynamics365, including first-hand looks at how companies such as Lenovo, Sonepar, Ford Motor Company, Omnicom and more are using these new capabilities in transformative ways. Click the image below to watch today!   Power Platform Community Conference 2024 is here! It's time to look forward to the next installment of the Power Platform Community Conference, which takes place this year on 18-20th September 2024 at the MGM Grand in Las Vegas!   Come and be inspired by Microsoft senior thought leaders and the engineers behind the #PowerPlatform, with Charles Lamanna, Sangya Singh, Ryan Cunningham, Kim Manis, Nirav Shah, Omar Aftab and Leon Welicki already confirmed to speak. You'll also be able to learn from industry experts and Microsoft MVPs who are dedicated to bridging the gap between humanity and technology. These include the likes of Lisa Crosbie, Victor Dantas, Kristine Kolodziejski, David Yack, Daniel Christian, Miguel Félix, and Mats Necker, with many more to be announced over the coming weeks.   Click here to watch our brand-new sizzle reel for #PPCC24 or click the image below to find out more about registration. See you in Vegas!       Power Up Program Announces New Video-Based Learning Hear from Principal Program Manager, Dimpi Gandhi, to discover the latest enhancements to the Microsoft #PowerUpProgram. These include 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 image below to find out more!   UPCOMING EVENTS Microsoft Build - Seattle and Online - 21-23rd May 2024 Taking place on 21-23rd May 2024 both online and in Seattle, this is the perfect event to learn more about low code development, creating copilots, cloud platforms, and so much more to help you unleash the power of AI.   There's a serious wealth of talent speaking across the three days, including the likes of Satya Nadella, Amanda K. Silver, Scott Guthrie, Sarah Bird, Charles Lamanna, Miti J., Kevin Scott, Asha Sharma, Rajesh Jha, Arun Ulag, Clay Wesener, and many more.   And don't worry if you can't make it to Seattle, the event will be online and totally free to join. Click the image below to register for #MSBuild today!   European Collab Summit - Germany - 14-16th May 2024 The clock is counting down to the amazing European Collaboration Summit, which takes place in Germany May 14-16, 2024. #CollabSummit2024 is designed to provide cutting-edge insights and best practices into Power Platform, Microsoft 365, Teams, Viva, and so much more. There's a whole host of experts speakers across the three-day event, including the likes of Vesa Juvonen, Laurie Pottmeyer, Dan Holme, Mark Kashman, Dona Sarkar, Gavin Barron, Emily Mancini, Martina Grom, Ahmad Najjar, Liz Sundet, Nikki Chapple, Sara Fennah, Seb Matthews, Tobias Martin, Zoe Wilson, Fabian Williams, and many more.   Click the image below to find out more about #ECS2024 and register today!     Microsoft 365 & Power Platform Conference - Seattle - 3-7th June If you're looking to turbo boost your Power Platform skills this year, why not take a look at everything TechCon365 has to offer at the Seattle Convention Center on June 3-7, 2024.   This amazing 3-day conference (with 2 optional days of workshops) offers over 130 sessions across multiple tracks, alongside 25 workshops presented by Power Platform, Microsoft 365, Microsoft Teams, Viva, Azure, Copilot and AI experts. There's a great array of speakers, including the likes of Nirav Shah, Naomi Moneypenny, Jason Himmelstein, Heather Cook, Karuana Gatimu, Mark Kashman, Michelle Gilbert, Taiki Y., Kristi K., Nate Chamberlain, Julie Koesmarno, Daniel Glenn, Sarah Haase, Marc Windle, Amit Vasu, Joanne C Klein, Agnes Molnar, and many more.   Click the image below for more #Techcon365 intel and register today!     For more events, click the image below to visit the Microsoft Community Days website.      

Tuesday Tip | Update Your Community Profile Today!

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.   We're excited to announce that updating your community profile has never been easier! Keeping your profile up to date is essential for staying connected and engaged with the community.   Check out the following Support Articles with these topics: Accessing Your Community ProfileRetrieving Your Profile URLUpdating Your Community Profile Time ZoneChanging Your Community Profile Picture (Avatar)Setting Your Date Display Preferences Click on your community link for more information: Power Apps, Power Automate, Power Pages, Copilot Studio   Thank you for being an active part of our community. Your contributions make a difference! Best Regards, The Community Management 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  

Super User of the Month | Ahmed Salih

We're thrilled to announce that Ahmed Salih is our Super User of the Month for April 2024. Ahmed has been one of our most active Super Users this year--in fact, he kicked off the year in our Community with this great video reminder of why being a Super User has been so important to him!   Ahmed is the Senior Power Platform Architect at Saint Jude's Children's Research Hospital in Memphis. He's been a Super User for two seasons and is also a Microsoft MVP! He's celebrating his 3rd year being active in the Community--and he's received more than 500 kudos while authoring nearly 300 solutions. Ahmed's contributions to the Super User in Training program has been invaluable, with his most recent session with SUIT highlighting an incredible amount of best practices and tips that have helped him achieve his success.   Ahmed's infectious enthusiasm and boundless energy are a key reason why so many Community members appreciate how he brings his personality--and expertise--to every interaction. With all the solutions he provides, his willingness to help the Community learn more about Power Platform, and his sheer joy in life, we are pleased to celebrate Ahmed and all his contributions! You can find him in the Community and on LinkedIn. Congratulations, Ahmed--thank you for being a SUPER user!

Tuesday Tip: Getting Started with Private Messages & Macros

Welcome to 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!   This Week's Tip: Private Messaging & Macros in Power Apps Community   Do you want to enhance your communication in the Community and streamline your interactions? One of the best ways to do this is to ensure you are using Private Messaging--and the ever-handy macros that are available to you as a Community member!   Our Knowledge Base article about private messaging and macros is the best place to find out more. Check it out today and discover some key tips and tricks when it comes to messages and macros:   Private Messaging: Learn how to enable private messages in your community profile and ensure you’re connected with other community membersMacros Explained: Discover the convenience of macros—prewritten text snippets that save time when posting in forums or sending private messagesCreating Macros: Follow simple steps to create your own macros for efficient communication within the Power Apps CommunityUsage Guide: Understand how to apply macros in posts and private messages, enhancing your interaction with the Community For detailed instructions and more information, visit the full page in your community today:Power Apps: Enabling Private Messaging & How to Use Macros (Power Apps)Power Automate: Enabling Private Messaging & How to Use Macros (Power Automate)  Copilot Studio: Enabling Private Messaging &How to Use Macros (Copilot Studio) Power Pages: Enabling Private Messaging & How to Use Macros (Power Pages)

Users online (7,516)