cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Brian-M
Super User
Super User

SQL Server - When a record is deleted?

I created a flow that creates a calendar event every time a new row is added to a sql table.  The calendar event ID is recorded in the SQL record upon creation.  I'm looking to create another flow that would then delete that calendar event when the corresponding sql record is deleted. However, there is no trigger for "When a record/row is deleted" in SQL Server.  Is there a workaround that would achieve the same objective?

1 ACCEPTED SOLUTION

Accepted Solutions
abm
Most Valuable Professional
Most Valuable Professional

Hi @Brian-M 

 

I have made a tutorial video regarding this. Please have a look.

 

https://youtu.be/OG_PH1LlnlY

 

Thanks



Did I answer your question? Mark my post as a solution!

If you liked my response, please consider giving it a thumbs up


Proud to be a Flownaut!

Learn more from my blog
Power Automate Video Tutorials

View solution in original post

13 REPLIES 13
Heartholme
Super User
Super User

Hi @Brian-M

 

Like you say, there isn't a trigger for when a record is deleted in an SQL Table. A work around here is to have a stored procedure which stores deleted rows in a temp table for example (https://stackoverflow.com/questions/25000968/how-to-get-list-of-deleted-records-in-sql). Select a recurring trigger of let's say 10 minutes and the next action should be to run the stored procedure. Every time you delete an event you finish your flow with putting in that event in another SQLTable/SPList/Excelworkbook etc. For each run of your flow, match up the SQL deleted rows with the calenderIDs in your Outlook deleted table, if there's any discreprancies, move forward and delete those records. This is a possible work around, but not the nicest solution. Is there a specific reason for why you're using a SQL server for this job? I would reccommend using a SP list or a custom dataverse table for this purpose, since you can easily run a trigger when a row/item is deleted: 

Heartholme_0-1660835145968.png

 

Hopefully this will help you on your way 🙂

 

{ If my post answered your question, please Accept it as a solution ✔ }
{ This will in turn help others find solutions to similar questions }

Best Regards
Heartholme

 

Brian-M
Super User
Super User

Thanks, I am working with a client and am restricted to their environment.  They have an app that stores data in a local sql server so unfortunately I'm limited in how I can handle this.

Heartholme
Super User
Super User

@Brian-M If the client have any SQL resources, I would cooprate with them to have a seperate temp. table with the deleted events, which you can call via a strored procedure. That would make it possible to do the synchronization between SQL and Outlook. Easiest way to connect to a SQL server is probably via a gateway installed on the server: 
https://docs.microsoft.com/en-us/power-automate/gateway-manage.

 

This solution requires a bit of work, so maybe it's not appropiate for the client to actually go for it. 

 

Let me know if you have any further questions. 

 

Best of luck. 

 

craig_01
Helper III
Helper III

@Brian-M Did you get a resolution to delete records.. I have a similar setup, im using a flow to pull sql data with holiday information into a sharepoint list (which is viewed as a calendar view).. However if a holiday entry is deleted from SQL, i need to keep the data updated on the sharepoint list. @Heartholme Any help of further guidance would be apprecaited also.

 

Regards

Craig

 

My situation ended up being a little different. The client and I determined that no records will be deleted in SQL, only added or changed. For your situation, maybe a flow that periodically checks, on a scheduled basis, the items in the sharepoint list against rows in SQL.  If the sharepoint record doesn't exist in SQL, delete it from Sharepoint.  Maybe have it auto-run once or twice a day? Or more frequent if needed.

 

Hopefully you're pulling some kind of unique record ID from SQL into sharepoint and you can just search for that in SQL.  If not, you'll have to try to match some of the data fields to each other, enough to say, "these are the same records", and either "do nothing" (if the corresponding SQL record exists) or delete the SP record if there is no corresponding SQL record.  Hope that helps.

craig_01
Helper III
Helper III

@Brian-M I have a unique SQL id for each record that is also fed into a column within the SharePoint list. At present i use the ID within an existing flow, and based on a condition either create a new record, or update an existing one... I will create a new flow for the deletion, can you give some guidance on the best way to build this flow with regards each element..

 

Thanks

The basics of the flow are:

1. Trigger = Schedule/Recurrence (every 10 mins or what ever you want)

2. Get Items (Sharepoint)

3. Get Rows (SQL)

4. Condition: If SP ID column = SQL ID, Do nothing (Yes), Else (No) Delete Item (Sharepoint)

 

You will likely need to convert your sharepoint column from a string to an integer to do the comparison though.

craig_01
Helper III
Helper III

@Brian-M Thanks for the reply... Can you provide a few points on converting the SP Column from a string to an Integer..

 

Thanks

Create a Compose action and use Int() function to convert string to an integer.  Example:

 

Int(Outputs('stringvalue'))

abm
Most Valuable Professional
Most Valuable Professional

Hi @Brian-M 

 

I have made a tutorial video regarding this. Please have a look.

 

https://youtu.be/OG_PH1LlnlY

 

Thanks



Did I answer your question? Mark my post as a solution!

If you liked my response, please consider giving it a thumbs up


Proud to be a Flownaut!

Learn more from my blog
Power Automate Video Tutorials
craig_01
Helper III
Helper III

Hi @abm very informative video, i hope to test this over the weekend.. My SQL table is a Sage200 table, i cant see that creating the trigger within this would create any issued. Natively its still just a SQL database used by Sage.

 

Could the trigger be created on a view? As i have a view that only shows Live no Completed orders, or how would i ensure i am looking at the ID of "Live" orders.

 

Thanks.

Brian-M
Super User
Super User

Thank you @abm, very helpful video.

abm
Most Valuable Professional
Most Valuable Professional

Under the SQL trigger procedure code you could add an extra check to make sure its the right record  or not. Add an If statement and execute the flow http url.

Thanks



Did I answer your question? Mark my post as a solution!

If you liked my response, please consider giving it a thumbs up


Proud to be a Flownaut!

Learn more from my blog
Power Automate Video Tutorials

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 (6,152)