Do not Implement Code Step 'Upsert Rows' in Coda if variable 'found' in Node.js is 0

I have three code steps in Pipe Dream. Trigger, Node.js and Coda. Everytime there is a trigger event, Node.js process it and find something and store the output in variable ‘found’. If ‘found’ is 0 , I dont want to implement the third code step which is the Coda Upsert Rows. How will I do that in pipedream ? Thanks. Below is my code in Node.js

export default defineComponent({
async run({ steps, $ }) {
console.log(steps);

var found = 0;

for(var a in steps.trigger.event.body.references){
  
  if(steps.trigger.event.body.references[a]['name'] == 'add_toCoda'){
    found = 1;
   
}


if(found==1){
  console.log('i-add');
}else{
  console.log('dili i-add');
} 

},
})

Hello @alyssagono,

I assume that you don’t want the third step to be executed if found is 0. In this case, you can call $.flow.exit('Reason') in your Node.js code to stop the workflow early. You can refer to the document here for more info Running Node.js in workflows - Pipedream

1 Like

Thanks! Helped a lot.