API workflow - changing thing

My app is a job board and I have the following 2 fields on every job

- Status
- Expiry date

The status field is a text field that would normally be set to “Live”. I would like this to change to “Expired” when the expiry date is reached. I figured this would require an API workflow so I’ve setup the following but it doesn’t work.

Any ideas where I’m going wrong?

7961391aa7e1ae02d4fc52a49767c31d70520b09_1_690x200

What do you mean by it doesn’t work?

One possible problem you may have is that an app on the Hobby plan doesn’t allow schedule API workflow, although you can get API workflows running other ways.

You might be interested in altering your app so that the status field is calculated on display instead of stored, so you don’t need to have anything altered on a schedule.

Thanks for your advice.

By not working I mean that the “Status” field is not changed to “Expired” when the Expiry date passes. I’m on a paid plan.

I like the sound of the status field being calculated on display as you suggest, but unsure how this would work exactly? How would I go about implementing something like that?

Some things to check:
. the server logs to see that the endpoint was invoked.
. the conditions that the database step is to be run.
. the search criteria matches the record you want changed.

An element could display a dynamic expression with something like expiry date < current date :formatted as, yes: expired, no: live

Or the Conditional tab of an element could be used with a similar date comparison, to alter various properties of the element.

Great, thanks. So I’ve checked the server logs and it’s not there. So am I not triggering the workflow properly?

Here’s what I’ve got:

Hi Josh,

I find the tiny font on the screenshots hard to read.

The endpoint definition looks okay.

The first step in the API workflow is scheduling the same workflow to run on the expiry date. You probably don’t want to do this, you probably want to schedule the endpoint to run from a different workflow, for example from a page button workflow.

Thanks for this. I felt like that 1st step must be wrong.

The problem is that I want the workflow to automatically run when the expiry date is reached. I suppose I could use a button on an admin-only page that I could click once a day to run the workflow on all jobs. Would that be a reasonable solution?

I couldn’t say which is more appropriate, but you have a choice:

  • Schedule to run on the expiry date (and time) when the user causes the record to be created. This means every live record has a schedule.

  • Have a recurring (or recursive) schedule to look for expiring records and process them.

Ah yeah! Makes sense. Thanks so much. Out of interest, which option is best from minimising resource usage?

It depends …

The batch" process has less schedules, but runs a search. It bunches the work into one time slot, which can be good to move workload into a time when few users are online, but is worse if user activity is spread across the 24 hours.

You’ll also need to consider whether the time component matters, and user vs batch timezones, it can make the difference of one day in expiry.

Thanks so much for your advice. I finally managed to get it working following your advice. Thanks again

2 Likes

Hi @josh7 would you mind to show the solution please?

I have a similar situation and i can’t figure out why my thing field “Expiry” don´t change.

Thank you :grinning:

1 Like

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