2014-09-27 94 views
1

我怎樣才能獲得唯一ID的列表?(說的文檔列表)獲得唯一ID列表

對於根級別項目(這意味着該項目是在文件列表中的第一級)時,我得到它的ParentUniqueId,它給了我它所在的列表的UniqueId。 現在我的問題是,我無法獲得唯一ID的列表(當我得到它的元),這樣我可以區分這ParentUniqueId或者是我的名單的唯一ID(在這種情況下,是文檔列表)或UniqueId該項目所在的另一個項目(文件內的文件夾或文件夾內的文件)。

非常感謝!

回答

1

要點是ParentUniqueId屬性存儲父容器ID,在List Item的情況下容器總是文件夾

實施例1:

假設爲一個文檔庫的結構如下:

Documents (library) 
    | 
    Document.docx (document item with id = 1) 

然後查詢:

/_api/Web/Lists/getByTitle('Documents')/items(1)/FieldValuesAsText?$select=ParentUniqueId 

將返回的SP.List.rootFolder值。

注:返回的值對應於Folder.UniqueIdList.Id

下面的查詢演示瞭如何檢索文檔庫RootFolder.UniqueId

/_api/Web/Lists/getByTitle('Documents')/rootfolder/UniqueId 

/_api/Web/GetFolderByServerRelativeUrl('Shared Documents')/UniqueId 

實施例2

假設爲一個文檔庫的結構如下:

Documents (library) 
    | 
    Orders (folder) 
     | 
     Document.docx (document item with id = 2) 

然後查詢:

/_api/Web/Lists/getByTitle('Documents')/items(2)/FieldValuesAsText?$select=ParentUniqueId 

將返回Orders文件夾的Folder.UniqueId值。

相應的查詢檢索Orders文件夾UniqueId屬性:

/_api/Web/GetFolderByServerRelativeUrl('Shared Documents/Orders')/UniqueId 
+1

謝謝!在我的情況下,URL是>>> _api/Web/GetFolderByServerRelativeUrl('Documents')/ UniqueId – 2014-09-29 05:21:21