0

我正在尝试验证列表是否具有特定的字段列表,它会不断返回列表中的所有现有字段,我该如何使这些工作正常进行?有没有更好的方法来实现我正在尝试的东西?

sp.web.lists.getByTitle("SliceBox").fields.select("Title","Body","Link","Picture","Visible").get()
    .then( (fields: any[]) => {
        console.log("> number of fields returned:", fields.length);

        fields.forEach(f => {
            console.log("> field:", f);
        })              
    })
    .catch( err => {
        console.log("> fields failure: ", err);
});
4

1 回答 1

1

我们将不得不在上述情况下使用“过滤器”

 sp.web.lists.getByTitle("SliceBox").fields.filter("((Title eq 'Title') or (Title eq 'Body'))").get()

我们可以为更多过滤器包含更多“或”。当我们使用“选择”时,它只返回该字段中的那些选定属性。意味着,如果我们使用select('Title')它只会返回所有字段的“标题”属性。

于 2018-07-01T23:19:02.663 回答