i want the database to trigger if the market is open or close by changing a value to 1 or 0
the market will work depend on it’s working hours if the market right now is closed database should trigger and set 0 to the close/open value
if the morning came and store now open database should trigger and set the value to 1
how can i do that?
more clear ?
You can use a backend API workflow for this. Read up on recursive workflows. You would essentially use a recursive workflow that schedules itself in the future, and either sets the value to 1 or 0 depending on whether you want to open or close the market. You could also use ‘ping pong’ workflows; an opener workflow that opens the market and schedules the closer workflow. And the closer workflow closes the market and schedules the opener workflow.
However, if you are just setting a database entry to either 0 or 1, you could achieve similar functionality with conditionals.
You could use an option set for ‘markets’ which contains an attribute numberfield for opening hours + closing hours of the market (ig. 9 and 17) and on your app you can use the conditional:
Currentdate time:extract hour > Optionset opening hour AND currentdatetime extract hour < Option set closing hour
If the above is true, the market is open, if the above is false the market is closed. This would work anywhere and you wouldnt need to use any workflows or WU to constantly change the DB from a 0 to a 1. You also wouldnt need to worry about something going wrong and accidentally leaving a market open or closed because a workflow failed.
The option set can also contain multiple markets. You would have to add a ‘timezone’ number attribute to the optionset, and adjust for the timezone difference in the conditional.
I actually used the condition.
but because I wanted to sort the stores based on two things
on top of the list I want to view open stores sorted by location who closed to the user
on bottom the closed stores and I could not manage to do that
okay I solved by adding two repeating groups on for open stores and I used the condition and the other for closed stores also i reverse the condition
thanks