Question

Code by Zapier: NameError: name 'input_string' is not defined

  • 22 June 2023
  • 1 reply
  • 58 views

Userlevel 1
Badge

Dear community,

I set up the following Zap:

 

The code is supposed to be a workaround for a problem by Greenhouse where the Zapier endpoint returns a candidate direct URL starting with “app2” which is not accessible for European customers and instead we would need to access the candidates with a link starting with “s101”. Thus, I wrote this code, using the syntax for importing input data as outlined in this official help article (https://help.zapier.com/hc/en-us/articles/8496326417549#limitations-with-code-steps-0-11).

old_substring = "app2"

new_substring = "s101"

input=input_data['input_string']

output=input.replace(old_substring, new_substring)

However, when testing it, it throws the error:

NameError: name 'input_string' is not defined

I am looking forward to your help!


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

1 reply

Userlevel 6
Badge +8

Hey there @greenhouseautomation!

Your output variable needs to be an object or an array of objects instead of just a value. Here is some revised code that should fix your issue :)

old_substring = "app2"
new_substring = "s101"
input = input_data['input_string']
new_string = input.replace(old_substring, new_substring)
output = [{'New String': new_string}]