Cancelling Scheduled API Workflow in the future?

Hi team,

Any ideas on how to cancel an API workflow that has been scheduled to run in the future?

appreciate your help.

regards

You probably want to put a marker on the thing it is scheduled on, so that when it runs it bypasses the steps.

2 Likes

Yep, that’s how I’d do it.

thanks @NigelG

so just to be clear, when you say “put a marker on the thing”, do you mean put a condition to the thing that has been passed to the scheduled workflow in the field highlighted in red at the bottom of the screenshot?

1 Like

No, I mean put a field on the thing that your API is working on, and use that in the actions on the workflow.

For Instance, if you want to email later on someone at a schedule date, you can create a Thing called “Email” and attached it to the User : User’s Email_scheduled_list

Then you definie as a condition at the endpoint level “When User’s Email_scheduled_list contains Email”. So if you want to cancel the email, you would remove Email from User’s Email_scheduled_list.

Hope it helps

1 Like

thanks @nicolas.daprigny

that makes sense.

Hello there @NigelG and @Rogelio!

just wondering, beacuse I’m working now in scheduling api workflows int he future, and the need to have something “automatic” that if I update the date, will delete the previous scheduled api workflow and create a new one

The thing is a POLICY (yes, insurance). And policies have expiration dates. It’s common practice that when you renew the policy, just move further in the future the expiration date.

So, I have a group, that contain’s the policy expiration date auto-binded. How could I do, if I pick a different expiration date and gets saved, to delete the previous API workflow and make a new one with the new date?

Ideas?

1 Like

@martin2 did you figure out a way to do this? kill the previously scheduled api workflow when the expiration date changes in the db?

@trevor what you’ll want to do is save the scheduled ID for whatever workflow you’re running, and save it to the object for use later. Part of your ‘update the date’ workflow would involve cancelling the old workflow (using the saved workflow ID) and then scheduling a new one. I think this should answer your question…
Step by step, using an example app:

  1. I created an endpoint, /policyworkflow, that sets the date, and saves the scheduled workflow ID for later.
  2. The endpoint /somethinginthefuture doesn’t do anything, just an example.
  3. Endpoint /updatepolicy a) cancels the workflow and b) sets a new date on the original policy

Does that answer your question?

9 Likes

That helped… Thank you very much!

thanks for the detailed explanation