Returning multiple values using Zapier

I need to return several variables depending on the input code. For instance, if the code is A, I return a specific set of values; if it’s B, I return another set; and if neither is entered, I should provide a default response. Below is my current implementation:

if (inputData.code === 'WSDCD-D2DUK') {
  outputVar = 'Company A';
} else if (inputData.code === '6P1CX-5U2TY') {
  outputVar = 'Company B';
} else {
  outputVar = 'Not Available';
}

return {result: outputVar};

What I need is a structure similar to this:

if (inputData.code === 'WSDCD-D2DUK') {
  outputVar = 'Company A';
  courseVar = 'ABC';
} else if (inputData.code === '6P1CX-5U2TY') {
  outputVar = 'Company B';
  courseVar = 'XYZ';
} else {
  outputVar = 'Not Available';
  courseVar = 'Not in one';
}

return {result: outputVar, course: courseVar};

To achieve this in Zapier, you’re on the right track. Simply extend your JavaScript code as you’ve demonstrated. Each if block should assign values to both outputVar and courseVar. After handling all conditions, return both variables in an object for Zapier to recognize them as separate outputs. Ensure that there are no syntax errors, like missing semicolons. If the logic becomes more complex, consider using a switch statement for clarity, which can also enhance readability especially with multiple conditions.

you could also consider using an array or object to map your codes to their respective values. it would keep your code cleaner, especially as the number of codes grow. e.g.
let mapping = { ‘WSDCD-D2DUK’: [‘Company A’, ‘ABC’],… };

then simply fetch them based on the inputData.code.