簡體   English   中英

使用@ pnp / sp獲取SPFx列表GUID

[英]Get SPFx List GUID with @pnp/sp

我借助於@ pnp / sp在SharePoint網站上創建一個新列表。

我創建列表並創建字段:

sp.web.lists.ensure("MySPListTest")
    .then((ler: ListEnsureResult) => {
        if (ler.created) {
            const batch = sp.web.createBatch();

            ler.list.fields.inBatch(batch).addText("TextField01");
            ler.list.fields.inBatch(batch).addDateTime("Date");
            ler.list.fields.inBatch(batch).addBoolean("Boolean",);
            ler.list.fields.inBatch(bacth).addLookup("Lookup", lookupListID, lookupFieldName);
        }
    })

我想添加一個查找字段,但是我不知道如何在我的網站上獲取列表的GUID。

我得到了清單:

let list: List = sp.web.lists.getByTitle("Trucks")

但我在任何地方都看不到ID。

在此處輸入圖片說明

關於如何獲取列表GUID的任何建議?

您忘記了執行請求(通過get方法)以返回List屬性:

let list = sp.web.lists.getByTitle(listTitle);
list.get().then(l => {
    console.log("List Id: " + l.Id);
}); 

參考

基本操作

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM