How to update list item in list 2 when list item in list 1 is deleted?

%3CLINGO-SUB%20id%3D%22lingo-sub-389368%22%20slang%3D%22en-US%22%3EHow%20to%20update%20list%20item%20in%20list%202%20when%20list%20item%20in%20list%201%20is%20deleted%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-389368%22%20slang%3D%22en-US%22%3E%3CP%3EHello%20everybody%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20have%20two%20lists%20in%20sharepoint%20online%20named%20Training%20%26amp%3B%20Registrations.%20In%20the%20Training%20list%2C%20I%20have%20add%20a%20few%20training%20names%20with%20a%20count%20of%20available%20seats%20(standard%2015).%20In%20the%26nbsp%3BRegistrations%20list%2C%20I%20add%20a%20person%20with%20a%20training%20to%20the%20list.%20On%20the%20background%20the%20count%20of%20available%20seat%20is%20for%20that%20training%20set%20to%2014%20(15%20-%201%20for%20the%20just%20added%20person).%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EMy%20question%20is%3A%20When%20I%20delete%20the%20person%20in%20the%20registrations%20list%2C%20the%20available%20seats%20in%20the%20training%20list%20need%20to%20be%20changed%20to%2015%26nbsp%3Bagain.%20How%20can%20I%20do%20that%3F%20My%20first%20step%20in%20the%20flow%20needs%20to%20be%20When%20an%20item%20is%20deleted.%20But%20what%20are%20the%20next%20steps%3F%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20hope%20anyone%20can%20help%20me%20with%20this%20problem%3F%3C%2FP%3E%3CP%3EKind%20regards%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EJeroen%20Laurijsen%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-389368%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EMicrosoft%20Flow%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3ESharePoint%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-481746%22%20slang%3D%22en-US%22%3ERe%3A%20How%20to%20update%20list%20item%20in%20list%202%20when%20list%20item%20in%20list%201%20is%20deleted%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-481746%22%20slang%3D%22en-US%22%3E%3CP%3EHi%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F296034%22%20target%3D%22_blank%22%3E%40JeroenLaurijsen%3C%2FA%3E%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThe%20problem%20I%20see%20with%20this%20scenario%20unfortunately%20is%20that%20using%20the%20%22When%20an%20Item%20is%20Delete%22%20step%20is%20VERY%20limited.%20The%20output%20from%20that%20trigger%20gives%20you%20no%20useful%20information%20on%20the%20deleted%20item.%20And%20while%20it%20DOES%20provide%20you%20the%20item's%20ID%2C%20using%20a%20follow-up%20'Get%20Item'%20using%20that%20ID%20returns%20nothing%20(which%20makes%20sense...%20since%20the%20item%20is%20deleted.%20I%20hoped%20beyond%20hope%20Microsoft%20would%20somehow%20cache%20the%20values%20for%20us).%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ESo%20trapping%20the%20DELETE%20event%20in%20Flow%20won't%20help.%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EAn%20alternative%2C%20however%2C%20is%20to%20take%20over%20the%20delete%20altogether.%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3COL%3E%3CLI%3ECreate%20a%20Flow%20where%20your%20trigger%20is%26nbsp%3B%3CSTRONG%3EFor%20a%20selected%20item%3C%2FSTRONG%3E%20from%20the%20SharePoint%20Triggers.%3C%2FLI%3E%3CLI%3EConfigure%20the%20Flow%20to%20point%20to%20your%20Registrations%20SharePoint%20list.%26nbsp%3B%3CUL%3E%3CLI%3EThis%20trigger%20now%20gives%20you%20full%20access%20to%20the%20item%20you%20want%20to%20delete.%20You'll%20select%20it%20in%20the%20list%20later).%3C%2FLI%3E%3C%2FUL%3E%3C%2FLI%3E%3CLI%3ECall%20your%20Flow%20something%20like%20%22Delete%20Registrations.%22%3C%2FLI%3E%3CLI%3EIn%20the%20ensuing%20steps%2C%20create%20a%20Flow%20that%20does%20essentially%20what%20your%20Decrement%20Flow%20does%20(query%20for%20the%20right%20class%2C%20get%20the%20count%2C%20and%20save%20back%20an%20incremented%20value).%3C%2FLI%3E%3CLI%3EThen%2C%20once%20you've%20completed%20those%20steps%20successfully%2C%20add%20a%20Delete%20Item%20step%2C%20and%20pass%20it%20the%20ID%20from%20the%20trigger%20item.%3C%2FLI%3E%3C%2FOL%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20didn't%20draw%20up%20the%20entire%20Flow%2C%20but%20here%20is%20the%20trigger%20and%20some%20placeholders%20for%20direction%3A%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20613px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F110100i61204E2EDB746FA1%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22delete-registration.PNG%22%20title%3D%22delete-registration.PNG%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EAnd%20because%20you%20used%20the%26nbsp%3B%3CSTRONG%3EFor%20a%20selected%20item%3C%2FSTRONG%3E%20trigger%20and%20pointed%20it%20to%20your%20Registrations%20SharePoint%20list%2C%20when%20you%20navigate%20to%20your%20list%20and%20select%20a%20single%20item%2C%20when%20you%20click%20the%20FLOW%20menu%2C%20you%20will%20have%20a%20%22Delete%20Registrations%22%20option%20to%20trigger%20your%20flow.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20559px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F110101i80B8BC3C08391CCD%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22flow.png%22%20title%3D%22flow.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI'd%20rather%20have%20the%20standard%20delete%20just%20work%2C%20but%20this%20is%20a%20viable%20alternative%20if%20you%20don't%20mind%20clicking%20a%20different%20DELETE%20button.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ELet%20me%20know%20if%20this%20helps.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E
New Contributor

Hello everybody,

 

I have two lists in sharepoint online named Training & Registrations. In the Training list, I have add a few training names with a count of available seats (standard 15). In the Registrations list, I add a person with a training to the list. On the background the count of available seat is for that training set to 14 (15 - 1 for the just added person). 

 

My question is: When I delete the person in the registrations list, the available seats in the training list need to be changed to 15 again. How can I do that? My first step in the flow needs to be When an item is deleted. But what are the next steps?

 

I hope anyone can help me with this problem?

Kind regards,

 

Jeroen Laurijsen

1 Reply

Hi @JeroenLaurijsen,

 

The problem I see with this scenario unfortunately is that using the "When an Item is Delete" step is VERY limited. The output from that trigger gives you no useful information on the deleted item. And while it DOES provide you the item's ID, using a follow-up 'Get Item' using that ID returns nothing (which makes sense... since the item is deleted. I hoped beyond hope Microsoft would somehow cache the values for us). 

 

So trapping the DELETE event in Flow won't help. 

 

An alternative, however, is to take over the delete altogether. 

 

  1. Create a Flow where your trigger is For a selected item from the SharePoint Triggers.
  2. Configure the Flow to point to your Registrations SharePoint list. 
    • This trigger now gives you full access to the item you want to delete. You'll select it in the list later).
  3. Call your Flow something like "Delete Registrations."
  4. In the ensuing steps, create a Flow that does essentially what your Decrement Flow does (query for the right class, get the count, and save back an incremented value).
  5. Then, once you've completed those steps successfully, add a Delete Item step, and pass it the ID from the trigger item.

 

I didn't draw up the entire Flow, but here is the trigger and some placeholders for direction:

delete-registration.PNG

 

And because you used the For a selected item trigger and pointed it to your Registrations SharePoint list, when you navigate to your list and select a single item, when you click the FLOW menu, you will have a "Delete Registrations" option to trigger your flow.

 

 

flow.png

 

I'd rather have the standard delete just work, but this is a viable alternative if you don't mind clicking a different DELETE button.

 

Let me know if this helps.