Help! If no class dates are scheduled beyond current/date time, listing should be removed

Hey all,

Editing this so that it’s clearer (taken from my post below):

The process is:

  1. When a listing creator sets up their class, they enter their class schedule using the Full Calendar plugin, e.g. classes on the 25th, 26th, 27th, 28th & 29th November at 8pm.

  2. Once they’ve submitted their listing for review, it becomes Type = Pending. The admin can then ‘approve’ the listing, which marks it as Type = Live. On my search page, I only show listings with Type = Live.

  3. Users can now book the classes from that listing by selecting an available time:

  1. Once the user has booked, we check to see if all available times are gone. If no future booking dates are available, we mark the listing as Type = NoDates.

  2. However, I don’t want to rely on a user to book a class or load the page before running a check to see if dates are available. Some classes may have 0 bookings, e.g. a class creator adds to their schedule: a class on 25th & 26th November at 5pm. They may have 0 bookings and 0 visits to their class page by the 27th November, so no user action will be able to trigger the listing Type of NoDates.

What I require is a background check across all listings to see if listings have upcoming class dates. If a listing has 0 future bookable class dates, then that listing should be marked as Type = NoDates (it’s like pending, but doesn’t require admin re-approval, just requires the user to add more dates on their dashboard for it to become Live again). I can also set up a ‘Send Email’ action to notify the class creator that they need to add more dates.

That means a workflow on page load of the activity won’t work because the listing should be Type = NoDates as soon as no future bookable dates are available.

Thanks guys

I have a half-working solution but it’s not really what I need. I’ve added a ‘Do every 0.5 seconds’ action, as can be seen below:

However, it requires a user to visit the page first, which won’t really work because I’ll be hiding listings with 0 dates from the search.

The main reason I want to do this is so that I can notify the class creators that they need to add more dates to their class schedule, so I need to rely on an automated process rather than someone visiting the page or clicking a button before the ListingStatus changes and the class creator receives an email notification.

I’ll keep trying, a solution can’t be too far off!

Edit: Maybe I need to schedule an API workflow?

I don’t quite understand your specific desired behavior, but think I have 2 ideas that may be helpful:

  • You could run a workflow on page load.
  • You could set a group to have conditional logic which shows the events when count > 0

Thanks for the reply!

Let me try and explain a bit more clearly:

  1. When a listing creator sets up their class, they enter their class schedule using the Full Calendar plugin, e.g. classes on the 25th, 26th, 27th, 28th & 29th November at 8pm.

  2. Once they’ve submitted their listing for review, it becomes Type = Pending. The admin can then ‘approve’ the listing, which marks it as Type = Live. On my search page, I only show listings with Type = Live.

  3. Users can now book the classes from that listing by selecting an available time:

  1. Once the user has booked, we check to see if all available times are gone. If no future booking dates are available, we mark the listing as Type = NoDates.

  2. However, I don’t want to rely on a user to book a class or load the page before running a check to see if dates are available. Some classes may have 0 bookings, e.g. a class creator adds to their schedule: a class on 25th & 26th November at 5pm. They may have 0 bookings and 0 visits to their class page by the 27th November, so no user action will be able to trigger the listing Type of NoDates.

What I require is a background check across all listings to see if listings have upcoming class dates. If a listing has 0 future bookable class dates, then that listing should be marked as Type = NoDates (it’s like pending, but doesn’t require admin re-approval, just requires the user to add more dates on their dashboard for it to become Live again). I can also set up a ‘Send Email’ action to notify the class creator that they need to add more dates.

That means a workflow on page load of the activity won’t work because the listing should be Type = NoDates as soon as no future bookable dates are available.

Does that make more sense? I hope so!

For a background process you need an API workflow. When a listing creator sets up their class, you could schedule an API workflow for the last available date. In this API workflow, you would set the listing to NoDates and also email the listing creator. Search for API workflows in the references and/or forums to learn more.

Yeah it looks like an API workflow is the way to go. The only issue that the user can update their class schedule (add/remove class dates) from their dashboard at any point, so if I schedule the API workflow for a certain date, that date could change (e.g if a class date or time has been removed or added). Can I make changes to the API workflow each time the user updates their class schedule?

Yes, there is an action to cancel a scheduled API workflow. You would then schedule a new one with the new date. Read about cancelling scheduled workflows here.

1 Like

I’ve been reading up on Workflow APIs and have been building this, but I have come across one issue. Here’s what it looks like so far:

1. When a user creates a listing, I’ve scheduled the API workflow to run when the last item’s start date begins.

2. This is the API workflow scheduled.

I wasn’t too sure what to add for the ‘Thing to change’. I added Search for Listings: first item

  1. On a separate page, when I update the class schedule, I want to cancel the original scheduled API workflow, but I’m not sure what the ID is.

Should I create a new data type and store the ID as text? If this is the way to go, I guess I ‘Do a search for’ the Workflow data type’s ID, but wouldn’t be sure which constraints to use.

Any advice is super appreciated :slight_smile:

When you schedule the API, also save its id to the thing (listing?) you scheduled it on, in a field called ‘current_wf_id’ for example. Then when you want to cancel just search for the listing you want to reschedule a workflow for and set the id for the cancellation to that listing’s current_wf_id.

Edit: Re your first question, I think you should be passing a listing to your workflow as a parameter, unless the search you have put in there now will always return the listing you want. If not, here’s what you should do:

  1. Add a parameter of type listing to your API workflow. Let’s call this pListing
  2. Change Thing to change to pListing
  3. On the page, when schedule the workflow, there should now be a parameter pListing toset. Set it to the listing you just created/changed.
1 Like

Awesome thanks!

Everything made sense except for this bit:

When you schedule the API, also save its id to the thing (listing?) you scheduled it on, in a field called ‘current_wf_id’ for example. Then when you want to cancel just search for the listing you want to reschedule a workflow for and set the id for the cancellation to that listing’s current_wf_id.

• Should I create a new text field for the Listing data type (called ‘current_wf_id’ in this case)?
• If I should create a new field, what content goes inside? I can’t see ‘workflow ID’ to save to any existing fields, unless I add it as another action (after creating the Workflow) and then referring to that step, like this:

Here’s where I got to with the other steps:

• I created the pListing parameter:

• I’ve given pListing a listing (the listing hadn’t yet been created so I just referred to step 1 which is creating the listing).

Hopefully I’m along the right lines!

From your screenshots, your ‘ID’ seems to be the equivalent of my ‘current_wf_id’. Is that correct? Or is the field ID supposed to identify the listing? If so, then don’t use this to store the workflow id. Create a new text field named current_wf_id or something similar and use that instead of ID in your first screenshot.

The rest of looks okay to me.

Now that you are saving the API WF’s ID against the Listing, when you want to reschedule your workflow, just search for the current listing’s current_wf_id in your cancel scheduled API workflow step.

Sorry, ideally I would show you an example but I’m in a bit of a rush. Besides, you seem to be quite close anyway.

1 Like

Yup, I was using ID as a placeholder rather than creating a new field, I’ve now created ‘Current WF ID’ as a field though, so I’ve set it up to say ‘Current WF ID’ = Result of step 4 (Schedule API workflow).

The only issue now is cancelling the correct Workflow. Inside my ‘Cancel Scheduled API Workflow’, I’m running ‘Search for Listings’s Current WF ID’ as the API ID. This is returning an error though, as it’s currently a ‘List of Texts’ but should return a single text. Should I do ‘:first item’ as I’ll be narrowing down to the exact listing anyway?

Inside my search constraint, should I have something like ‘unique ID = parent group listing’s unique ID’?

Thanks :slight_smile:

It depends on how your page/group is set up, but yes, if you’re using a search you’ll need to constrain it to get to the exact listing you want. Rather than do a search for, can you not simply say Parent group listsing’s Current WF ID?

If you end up using a search then yes, definitely.

1 Like

Thanks you, you’ve helped so much :)! Got it all up and running now. Woohoo!

1 Like

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