Question

Exit a zap through a Code by Zapier step

  • 4 August 2023
  • 4 replies
  • 154 views

Hi, 

I’m looking at some custom logic with a Code by Zapier step, and it would be convenient if under certain expected conditions, I can just terminate the Zap. I know I can return a value that can then be used in a Filter step but that just seems like an overkill. 

I’ve tried returning `null` (using the Javascript actions) and `process.exit(0)` but both of these result in a Zap error. 

Has anyone found a way to do this more gracefully without a Filter step? 

 


This post has been closed for comments. Please create a new post if you need help or have a question about this topic.

4 replies

Userlevel 7
Badge +14

Hi @GeorgiM 

Good question.

A Code step can be the last step in a Zap.

You just have to make sure it returns an output.

Examples: https://help.zapier.com/hc/en-us/articles/8496197098253-JavaScript-code-examples-in-Zaps

 

Thanks @Troy Tessalone.

In my case, the Code step is actually not the last step in the Zap. The step does quite a bit of transformation and conditional logic and in some of the cases it would be convenient that the Zap can just terminate and not proceed with subsequent steps. 

Userlevel 7
Badge +14

@GeorgiM 

You would need to add a Filter step after the Code step.

Userlevel 7
Badge +14

@GeorgiM 

Another approach would be to conditionally fire a webhook in the Code step.

That webhook would trigger another Zap.