I’m working on a Zapier code step that needs to evaluate an input value and return a corresponding rating from 1 to 10. The logic should check if my input matches a specific value and return the appropriate rating.
Here’s what I’m trying to do:
if (inputData.amount === '9500000') {
result = '3';
} else {
result = inputData.amount;
}
But I keep getting this error message saying I must return a single object or array of objects. I’m not sure how to structure my return value properly in Zapier’s code environment. What’s the correct way to format the output so Zapier accepts it?
This is a super common issue when you’re starting with Zapier code steps. You can’t just assign values to variables - you need to return them as objects that Zapier can actually use.
Here’s how to fix your code:
let rating;
if (inputData.amount === '9500000') {
rating = '3';
} else {
rating = inputData.amount;
}
return {rating: rating};
Zapier needs the output as an object with named properties. Whatever you name that property (‘rating’ here) becomes the field you can reference in later steps. Don’t forget the return statement - without it, Zapier has no clue what data to pass along.
The problem is that Zapier code steps require structured output objects rather than just variable assignments. You need to return your results in a format that Zapier can handle. Consider this approach:
This method directly returns the object without creating intermediate variables. The property ‘result’ will be accessible in subsequent Zapier steps, and you can name it according to what fits your workflow best, ensuring it is enclosed in an object with a return statement.
yeah, zapier’s weird about this. just wrap everything in an object when you return. try return {amount_rating: inputData.amount === '9500000' ? '3' : inputData.amount}; - does the same thing in one line.