【问题标题】:Retuning multiple variables with Zapier使用 Zapier 重新调整多个变量
【发布时间】:2018-10-26 17:53:23
【问题描述】:

我需要能够根据代码返回一些变量。如果代码 A 则返回这些。如果代码 B 则返回这些。在没有代码的情况下,返回这些。

这是我目前所拥有的。

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

return {result: output};

而我需要的是这样的:

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

return {result: output, course};

【问题讨论】:

  • 底部代码看起来像写的那样工作。您在 Zapier 中看到错误了吗?

标签: zapier


【解决方案1】:

看起来您没有定义 course 变量。但是,output 不需要定义,因为它在 Code by Zapier 范围内可用。

我稍微修改了代码以反映您的用例。

var inputData = {'code': 'D2DUK'}
//Remove the line above before pasting in the Code step. 
//You will need to configure it in the Zap.

//Defining the variables here.     
let course = '';
let company = '';

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

//Returning the JSON object with the keys company and course.
return {company, course};

【讨论】:

  • @allen-awf 如果此答案解决了您的问题,请投票并标记为正确。 (info here)
猜你喜欢
  • 1970-01-01
  • 2015-09-23
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2022-10-04
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多