Backend workflow: How to auto-update jobPost status to "Expired" when expiryDate has passed?

Hi everyone,

I have a jobPost data type with an expiryDate (date field) and jobPostStatus (which uses an option set). I want Bubble to automatically check if the expiryDate is < current date and time (expired), and if so, update the jobPostStatus to the “Expired” option.

What’s the best way to handle this and what steps should I take?

Appreciate your help!

  • Create a backend workflow with a parameter for jobPost
  • Add an action to the workflow to make a change to that jobPos → jobPostStatus = Expired
  • Wherever you have the workflow to create/modify the jobPost with expiryDate, add an action to “schedule an API workflow.” The schedule action should point to your new backend workflow and set the scheduled date as the expiryDate.

Keep in mind:

  • If the date can change, you’ll need to cancel the workflow and reschedule. Save the scheduled workflow ID to a text field on jobPost record. The ID is generated as a “result of” the scheduling action. When it’s time to cancel (if necessary), run the “cancel schedule api workflow” action and refer to the jobPost’s scheduled workflow ID.
  • You may want to put a condition on the backend workflow so that it runs only when the jobPost’s status is whatever status it should be in for this flow (active, published, etc.) This is just in case jobs can also be things like Hired, Archived, etc. and you don’t want Expired to overwrite it.

Hope this helps!

Gaby
Coaching No Code Apps

Thanks, Gaby, but I think there was a misunderstanding. I’m not trying to check expiry status manually or only when a user interacts with the app.

What I’m hoping to achieve is an automated process that runs regularly in the background and updates any jobPost whose expiryDate is in the past by changing its jobPostStatus to “Expired” (an Option Set value).

In other words, I want Bubble to periodically check all jobPosts (e.g., every hour or daily) and automatically update those that have expired — without needing any user to trigger it.

How can I set up a backend workflow or use Scheduled API workflows to accomplish this?

Thanks for your input!

This isn’t the right way to approach it. The way we approach scheduling things is that when we set the expiry date, we schedule a task to run at that time, which will update it at the correct time.

It’s incredibly inefficient for a computer to be continuously scanning all of the job posts to update those that have expired. You do not need a user to trigger it.

If you think about it, if you want to leave the house at 3 PM, you don’t check if it’s 3 PM every second of the day. Instead, you set an alarm which notifies you when it’s 3 PM so that you can leave.

In the same way, a scheduled workflow will start running at that time, so that you can run the logic rather than checking every X seconds.

Simply in the workflow where you create the job with an expiry date or update it, schedule the workflow which will run on the expiry date to update its status.

3 Likes

:backhand_index_pointing_up: What @georgecollier said!

We’re suggesting a more appropriate approach to get you the result you’re looking for. Schedule the workflow to run on the expiration date so there’s no need for excessive and unnecessary checks (which would increase your workload consumption, and at scale, the cost of your app).

A user has to interact with the app in order to create/modify the job, so the trigger to schedule the backend status change workflow should happen at the same time.

1 Like

Thanks ! I have implemented your method. Much appreciated.

1 Like