Pausing a workflow

I have a workflow created to triggered when a new invoice is created. Now I have a moment in the month where I am going to create around 200 invoices, but I don't want the workflow to be triggered during this moment. The 200 invoices are always created at the same moment in month. Currently the only way to avoid the workflow to be triggered would be to put the workflow in stagging mode on the specific date, but I would prefer to automate this. Any idea how to do this ?

Hi @MRConcept,

Yes, you can do this by creating a table with a value when it should be paused. Here is an example I use to check if a dispatch is running; if it is, I pause this workflow, until the status changes.

Create a table in your Retool db eg. workflow_flags.

Have one column name with the first row dispatchJobVisits (or in your case: pauseWorkflow) and another called is_running as a Boolean type and default False.

Then in the workflow after the startTrigger add a block that checks, in my case if another workflow is running. In your case it would check to see if you are doing your invoice batch.

In the next block create a branch and check if it is running. On one branch, the workflow ends there, on the other, it continues as normal.

To "switch" the workflow on or off you can do this either in another workflow or directly in your app with a simple resource query like:

-- Set flag to true
UPDATE workflow_flags
SET is_running = TRUE
WHERE name = 'dispatchJobVisits';

Hopefully that makes sense. Feel free to give it a go and ask questions if you get stuck.

2 Likes

I have to admit this idea is pretty ingenious, but it would still "cost me" 200 workflows for nothing. I am then assuming there is now way to "disable" temporarly the workflow. I think it would be a pretty usefull feature.

You are correct. There is no way to turn off a Workflow other than manually. My suggestion works but as you mentioned, it does cost. For one of my clients, it costs them over 1000 runs a day when they send out their teams. I can do a little digging later to see if it is already a feature request so we can +1 it.

I can't actually find an existing feature request for something like this! I'll document it internally and provide an update here as soon as there's news to share.

I assume this workflow is being triggered via webhook by some third-party service - is that right? And there's no way to conditionally send the webhook request on that side?

1 Like

@Darren would this be like some sort of "inverse cron" where you could schedule a time for a workflow to be inactive instead of a time for it to run?

Looking at enabling/disabling the webhook from the side that is calling the workflow makes sense. I also triggered an idea to perhaps creating a batching process in the invoice creation side with a parameter on that end that is typically set to run when the "number of invoices" is > 0 (i.e. whenever it learns there is a new invoice). Then on the bulk load day, the first step in the process is to set the parameter to run when "number of invoices" is > 200 (or 1,000,000 or whatever to block it). I guess you would also need to make sure the workffow is setup to handle an array of invoices coming in instead of one at a time, but that could also be a way to reduce workflow runs (assuming multiple can be processed in the time constraints of a workflow, and assuming you can handle a batch delay).

Anyway, will watch this thread to see what comes of this idea.

HI @jg80 thanks for the reply. I think this "disable workflow" has many different use cases, but my use case is that I want to be notified when a new invoice is created so I have this workflow that when a new invoice is created in QBO, it will add it to the retool database. Issue is at some point in the month I have all my montly invoices that are automatically created that I don't need to add to the crm so I would like to pause the workflow while I am doing my automatic invoices. I can't "pre assemble" all invoices in one since I am getting the webhook directly from QBO everytime a new invoice is created.

Gotcha - my brain goes to thinking of workarounds (maybe these monthly invoices have a certain attribute or class that differentiates them from other invoices, or some other invoice numbering pattern that could be a stand-in for class, etc.), but they all would still require the workflow to process the data. So as you mentioned, it sounds like pausing the workflow is the most straightforward for your use case since you essentially don't want to acknowledge the call from QBO (and I guess you can't indicate which types of invoices in QBO result in a post to the webhook).

That's almost exactly where my mind went initially, given the specific needs that @MRConcept outlined. It would probably be more flexible to expose an API endpoint, though. I'll let y'all know what the team thinks!

2 Likes

@MRConcept,
There are 2 viable approaches given here:

  1. As @jg80 mentioned, you can schedule via cron jobs IF you know exactly when you will be doing the monthly invoices. Since it seems this task is being done manually, this may not work for you.

  2. With the setup I mentioned earlier, you can pause your workflow with a single click. Once it's set up, triggering the pause is as simple as connecting it to a button or having it run on page load. Let me know if you'd like help setting this up.

Hi @Shawn_Optipath not sure to understand how I can make this happen via cron jobs. My monthly invoices are always created on the 26th (which is coming pretty soon!) in the early morning. What I understand for now is only option is to add a filter after the first trigger, but still it will consume 200+ workflow. Only way I see is to turn off the workflow is to turn off the webhook trigger is there an easier way ?

Sorry Maxime, I may have jumped the gun regarding cron jobs. Looks like it's back to adding the filter as the best option for now. 200 workflows is a fairly low cost for saving you time and a CRM headache. If you are close to your 5000 run limit you might be able to rework other workflows to bring your count down. For less critical data, sometimes I do a sync workflow every 24 hours, reducing the total number of workflow runs.

We should put in a feature request though and ask @Darren to help prioritize it.

1 Like

Thanks again @Shawn_Optipath. What I did is to add a filter after the trigger to look if currently it is the 26th of the month between 0:00 and 6:00am. Once again thanks for your help. How can we ask for a feature request? I would be in to add +1 to this

1 Like

I'll mark this as the accepted "Solution" for the time being, @MRConcept, but I've already documented this as a formal feature request internally. :+1: I'll let everybody know when there's been movement.

1 Like