2014-09-27 93 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