通过 Web 脚本编辑器添加动态字段时,我不确定如何遍历自定义字段。
当我测试时,我可以看到控制台中返回的字段
我们应用程序的每个实例的字段数量都不同。
这是我用来返回数据的代码。
return z.request(options)
.then((response) => {
response.throwForStatus();
const results = z.JSON.parse(response.content)._embedded;
return results;
});
我假设我需要遍历每个字段,提取 ID 和名称,然后将它们作为对象数组放回?
像这样的东西,唯一的问题是什么都没有返回?
return z.request(options)
.then((response) => {
response.throwForStatus();
const results = z.JSON.parse(response.content).results._embedded;
var cFields = [];
for (var i = 0; i < results.length; i++) {
cFields.push({'id': results.customFields[i].label});
}
return cFields;
});
任何指针?