Zapier 动态自定义字段

问题描述 投票:0回答:1

我正在尝试提供来自平台的自定义字段作为输入字段,我过去曾使用另一个平台和 Zapier 的旧 UI 完成过此操作。现在看来没那么简单了

const options = {
  url: 'https://edapi.campaigner.com/v1/Database',
  method: 'GET',
  headers: {
    'X-API-KEY': bundle.authData.ApiKey
  },
  params: {
    'ApiKey': bundle.authData.ApiKey
  }
};

return z.request(options).then((response) => {
  response.throwForStatus();
  const results = response.json;

const col = results.DatabaseColumns.filter((item) => item.IsCustom).map((item) => {
    return {
      ...item,
      id: item["ColumnName"],
    };
  });

  return col});

这就是我尝试用于操作的内容。我对触发器使用同样的方法,它可以在那里工作,但不能作为动态字段选项以及其他标准输入。

不确定是否需要调整代码或者是否可以调用触发器将拉取的数据?

这是字段的视觉效果,但我需要它来提取并提供自定义字段。这就像最喜欢的颜色等等。

Image of Zap

如有任何帮助,我们将不胜感激。

dynamic
1个回答
0
投票

我能够使用此代码:

// Configure a request to an endpoint of your api that
// returns custom field meta data for the authenticated
// user.  Don't forget to congigure authentication!

const options = {
  url: 'https://edapi.campaigner.com/v1/Database',
  method: 'GET',
  headers: {
    'X-API-KEY': bundle.authData.ApiKey
  },
  params: {
    'ApiKey': bundle.authData.ApiKey
  }
};


return z.request(options).then((response) => {
  response.throwForStatus();
  const results = response.json;

  var col = results.DatabaseColumns.filter((item) => item.IsCustom).map((item) => {
    return {
      ...item,
      key: item["ColumnName"],
      value: item["ColumnName"]
    };
  });

  //var col = col.filter(items => ['FirstName', 'LastName'].indexOf(items) >= 0 )
  for (var i = col.length; i--;) {
    if (col[i].key === 'FirstName' || col[i].key === 'LastName' ) {
        col.splice(i, 1);
    }
    }


  return col});
    
    
    /*
    return [ 
      {
        "key": "FirstName",
        "value":"First Name"
      },
      {
        "key": "LastName",
        "value": "Last Name"
      },
      {
        "key": "Test",
        "value": "Test 2"
      },
      */
      
© www.soinside.com 2019 - 2024. All rights reserved.