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

Copper 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.