Actions based on server time

Hi there, good morning to all.

I have a business-critical situation on the portal that I’m developing with Softr that may actually render my entire web portal unfit for purpose if I don’t solve it.

My application is finance-related and people get really upset if finance-related things don’t work well, so I need to get this one right.

Now, enough of context. My problem, in simple terms is: I need to have a record list that the user can only update during business hours (say 9am to 5pm in server time).

I could easily get a workaround using conditional filters and a Yes/No field “Business Hours” on AirTable, with an external app on running a VPS with a scheduled task to set that field to “Yes” at 9am on Mon/Tue/Wed/Thu/Fri and to “No” at 5pm on Mon/Tue/Wed/Thu/Fri. Then, if that field is “Yes”, the conditional filters will display the list with records, if that field is “No” then the list with records will not be displayed.

But I have a small problem. If someone logs in at 4.59pm they will get the field set to “Yes”, so the list of records will be updated. Then, if they take their time to update the record and they only press “Update” at 5.05pm, the update will go through, even though the button was pressed outside the business hours (and the Airtable field was already “No” when they pressed the “Update” button).

What are the possible workarounds that I can do to synchronise the “Update” button action with Airtable so that an “Update” attempt with the field set to “No” will fail, even if the user screen is out of date?

Thanks

Update - I think I’m nearly there with the solution.

I think I can add an event listener for the Update Record button and then put an extra validation that checks the server time and rejects the update if the server time is outside of the business hours range using a code like the one in this link: Extra form validation after submit?

So now I have only one final question: what is the event listener name for when the user submits the records for update but the records haven’t been updated yet?

I found this listener here: Action Buttons - Update Records event listeners but it won’t help me as it is triggered after the update has been made, and I want to be able to block the update.

Thanks

What about creating an automation in airtable which checks the created time and if it’s created outside of the allowed time, to place a tag/status on that record notifying such. Then, use that tag to filter them out of your conditional form so the user can’t see it, and notify the user that the submission didn’t go through via email because of the time. You could even show that information for them in the dashboard and make it easy for them to re-submit during business hours the next day.

1 Like