Skip to main content
Question

Exit a zap through a Code by Zapier step

  • August 4, 2023
  • 4 replies
  • 593 views

GeorgiM

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

Troy Tessalone
Zapier Orchestrator & Solution Partner
Forum|alt.badge.img+14
  • Zapier Orchestrator & Solution Partner
  • August 4, 2023

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

 


GeorgiM
  • Author
  • Beginner
  • August 4, 2023

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. 


Troy Tessalone
Zapier Orchestrator & Solution Partner
Forum|alt.badge.img+14
  • Zapier Orchestrator & Solution Partner
  • August 4, 2023

@GeorgiM 

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


Troy Tessalone
Zapier Orchestrator & Solution Partner
Forum|alt.badge.img+14
  • Zapier Orchestrator & Solution Partner
  • August 7, 2023

@GeorgiM 

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

That webhook would trigger another Zap.