如何使用 sp.web SPFX 检索计算列值

How to retrieve a calculated column value using sp.web SPFX

我正在创建一个 SPFX (ReactJS/TypeScript) webpart 并使用:

let docs = sp.web.lists.getByTitle("Case Documents").items.select("ID","Title","CaseID").orderBy("Modified", true).get();   

尝试从 SharePoint DOC 库中检索列值。 CaseID 是查看 SP 列表的查找列。查找列中有从其他列表填充的值。

我可以从图书馆获取 Id 和 Title 值,但不能获取 CaseID(查找列)。 我收到此错误:

Uncaught (in promise) Error: Error making HttpClient request in queryable [400]  ::> 
{"odata.error":{"code":"-1, Microsoft.SharePoint.SPException","message":
{"lang":"en-US","value":"The query to field 'CaseID' is not valid. 
The $select query string must specify the target fields and the $expand query string must contains CaseID."}}}
    at new HttpRequestError (parsers.js:130)
    at Function.<anonymous> (parsers.js:145)
    at step (tslib.es6.js:99)
    at Object.next (tslib.es6.js:80)
    at fulfilled (tslib.es6.js:70)
HttpRequestError @ parsers.js:130
(anonymous) @ parsers.js:145
step @ tslib.es6.js:99
(anonymous) @ tslib.es6.js:80
fulfilled @ tslib.es6.js:70

知道是什么原因造成的吗?

您可以通过以下方式获取查找列值的查找值:

let docs = sp.web.lists.getByTitle("Case Documents").items.select("ID","Title","CaseID/Title", "CaseID/ID").expand("CaseID").orderBy("Modified", true).get();