Data type: first item workflow not behaving as expected

Hi all,

Context: I am creating a time slot based queue, where users (called players) can join the queue, upon which a 10 second timer starts for their slot. The queue is one at a time, so if theres two players in the queue, the first player has 10 seconds, after which the first player is deleted and the next player has 10 seconds.

Find below an example of how it should work:
Player 1 enters their name and presses the button “Join the queue” → this creates an entry into my players data table with the players name and a timer variable set at 10 (number of seconds they have)
Player 1 is displayed in the queue (repeating group) and is placed in the currently playing section (group)
Player 1 timer starts counting down from 10 (based on a workflow that reduces the timer variable by 1 when "Do every 1 seconds and Players: first item is not empty)
Player 2 joins the queue (same logic as above)
Player 1 timer reaches 0 → Player 1 is deleted from the player table
Player 2 is placed in the currently playing section and their timer starts counting down from 10
Player 2 timer reaches 0 → Player 2 is deleted from the player table
[Repeat]

For player 1 this flow works as expected. However for player 2, when their timer reaches 0 they are not deleted for some reason and their timer keeps going down to negative infinity.

My hunch is this has something to do with my workflow logic, which does a search on “Players: first item” i.e., the first item in my data table. I suspect that for some reason, my delete workflow doesn’t recognise player 2 as the first item after player 1 is deleted. Has anyone come across this or knows a way to ensure that the first item is refreshed?

I have attached screenshots below of both what is happening and the workflow logic I have implemented.

Thanks in advance for any help!

What is happening: (note the timer going into negative in screenshot 2)


How my data structure looks (after player 1 has been deleted)

Workflows



Since I don’t see the properties of this workflow, I like to ask. What is the Run this property? If it is Just once, it behaves like you described.

It needs to be Everytime.
image

Thank you hergin! I hadn’t appreciated this aspect of workflows. This solved it :smile:

This topic was automatically closed after 69 days. New replies are no longer allowed.