Pipedream : Make a Condition before Executing an Action

634 views Asked by At

I was tasked to automate updating rows in Coda. I am currently testing out upsert rows. I want to configure it to only run if the value of {{steps.trigger.event.body.references[2].name}} is ‘add_to_Coda’. How am I going to do that in pipe dream ?

2

There are 2 answers

0
Bánh Gạo On

You can add the Filter action -> Continue execution if a condition Is met right before the action to update rows.

  • Initial value: {{steps.trigger.event.body.references[2].name}}
  • Condition: [Text] Matches exactly
  • Second value: add_to_Coda
0
Slav Pilus On

Using the filter step as already pointed out will work for your case. It is however pretty inflexible tool - your check must be against a string and won't work if it has null value or if it's a boolean.

I personally use a nodeJS step e.g.:

export default defineComponent({
  async run({ steps, $ }) {
    if(steps.trigger.event.properties["Automation Status"].select 
      && steps.trigger.event.properties["Automation Status"].select.name
      && steps.trigger.event.properties["Automation Status"].select.name.includes("To Do")) {
        return;
      }
    return $.flow.exit()
  },
})

Basically you can do all you checks and return $.flow.exit() if you don't want to continue with the pipe, and simply return if you do.