gpt4 book ai didi

sharepoint - 为什么 条件会被 SharePoint 列表服务的 GetListItems 方法忽略

转载 作者:行者123 更新时间:2023-12-03 16:48:54 24 4
gpt4 key购买 nike

尽管我在我的共享点列表服务的 GetListItems 查询中指定了一个 ViewFields 元素,但会返回所有字段。以下代码构建请求:

XmlDocument xmlDoc = new System.Xml.XmlDocument();
XmlNode query = xmlDoc.CreateNode(XmlNodeType.Element, "Query", "");
XmlNode viewFields = xmlDoc.CreateNode(XmlNodeType.Element, "ViewFields", "");
XmlNode queryOptions = xmlDoc.CreateNode(XmlNodeType.Element, "QueryOptions", "");

... set query ...

viewFields.InnerXml = "<FieldRef Name='LinkFilename' /><FieldRef Name='FileDirRef' /><FieldRef Name='FileLeafRef' />";

queryOptions.InnerXml = "<IncludeMandatoryColumns>FALSE</IncludeMandatoryColumns><DateInUtc>TRUE</DateInUtc><Folder>Resource Management Tools</Folder><ViewAttributes Scope='Recursive' />";

XmlNode xmlNode = SharePointListWebService.GetListItems(
_listServiceConfigurationSettings.ListName,
string.Empty,
query,
viewFields,
null,
queryOptions,
null);

根据 fiddler 的说法,这会导致以下肥皂信封被发布到列表服务:
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<GetListItems xmlns="http://schemas.microsoft.com/sharepoint/soap/">
<listName>Shared Documents</listName>
<viewName />
<query>
<Query xmlns="">
<Where>
<And>
<Contains>
<FieldRef Name="FileLeafRef" />
<Value Type="Text">.xls</Value>
</Contains>
<Geq>
<FieldRef Name="Modified"
IncludeTimeValue="True" />
<Value Type="DateTime">2010-05-10T11:53:32Z</Value>
</Geq>
</And>
</Where>
<OrderBy>
<FieldRef Name="FileDirRef" />
</OrderBy>
</Query>
</query>
<viewFields>
<ViewFields xmlns="">
<FieldRef Name="LinkFilename" />
<FieldRef Name="FileDirRef" />
<FieldRef Name="FileLeafRef" />
</ViewFields>
</viewFields>
<queryOptions>
<QueryOptions xmlns="">
<IncludeMandatoryColumns>FALSE</IncludeMandatoryColumns>
<DateInUtc>TRUE</DateInUtc>
<Folder>Resource Management Tools</Folder>
<ViewAttributes Scope="Recursive" />
</QueryOptions>
</queryOptions>
</GetListItems>
</soap:Body>
</soap:Envelope>

以及从服务返回的以下soap响应:
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<GetListItemsResponse xmlns="http://schemas.microsoft.com/sharepoint/soap/">
<GetListItemsResult>
<listitems xmlns:s='uuid:BDC6E3F0-6DA3-11d1-A2A3-00AA00C14882'
xmlns:dt='uuid:C2F41010-65B3-11d1-A29F-00AA00C14882'
xmlns:rs='urn:schemas-microsoft-com:rowset'
xmlns:z='#RowsetSchema'>
<rs:data ItemCount="19">
<z:row ows_LinkFilename='[SENSITIVE DATA].xls'
ows_FileDirRef='278;#sites[SENSITIVE DATA]'
ows_FileLeafRef='278;#[SENSITIVE DATA].xls'
ows_MetaInfo='278;#Subject:SW| vti_parserversion:SR|12.0.0.6421 ContentTypeId:SW|0x0101006C2E647253A1074FB6079F08E5F2A395 _Author:SW|[SENSITIVE DATA] _Category:SW| vti_author:SR|[SENSITIVE DATA] _Comments:SW| vti_approvallevel:SR| vti_categories:VW| vti_cachedcustomprops:VX|vti_approvallevel vti_categories Subject vti_assignedto Keywords _Author _Category _Comments vti_assignedto:SR| Keywords:SW| vti_modifiedby:SR|[SENSITIVE DATA]'
ows__ModerationStatus='0' ows__Level='1'
ows_Last_x0020_Modified='278;#2010-06-29T18:55:38Z'
ows_ID='278' ows_owshiddenversion='53'
ows_UniqueId='278;#{0E51B2B1-89A7-4895-8ECC-0FE7D420470C}'
ows_FSObjType='278;#0'
ows_Created_x0020_Date='278;#2009-03-09T16:06:41Z'
ows_ProgId='278;#' ows_Modified='2010-06-29T18:55:37Z'
ows_FileRef='278;#sites[SENSITIVE DATA].xls'
ows_DocIcon='xls'
ows_Editor='262;#[SENSITIVE DATA]' />
</rs:data>
</listitems>
</GetListItemsResult>
</GetListItemsResponse>
</soap:Body>
</soap:Envelope>

请注意 z:row 元素包含的字段比我在 ViewFields 条件中指定的多。我还在查询选项中将 IncludeMandatoryColumns 设置为 false。我做错了什么,或者我不明白 ViewFields 是如何真正工作的,因为我认为它会限制字段,即 SharePoint 列表服务返回的 z:row 属性。

最佳答案

我也一直在为这个问题苦苦挣扎。今晚我找到了一个似乎对我有用的解决方案......希望它对其他人也有帮助。

您的 viewFields 节点的结构很好......

   <viewFields>
<ViewFields xmlns="">
<FieldRef Name="LinkFilename" />
<FieldRef Name="FileDirRef" />
<FieldRef Name="FileLeafRef" />
</ViewFields>
</viewFields>

问题很可能是您的字段名称。显然,您必须使用内部名称而不是显示名称。确定内部名称的一种快速简便的方法是转到列表的“列表设置”页面并将鼠标悬停在列表中的每一列上。浏览器的状态栏会显示类似这样的 URL..
http://YOUR_SITE/_layouts/FldEdit.aspx?List=%7B12345678%2D1234%2D1234%2D1234%2D123456789012%7D&Field=INTERNAL_FIELD_NAME

对于要从​​ GetListItems() 服务返回的每个字段,使用此处显示的内部字段名称。例如,
<FieldRef Name="LinkFilename" />

....可能需要写成...
<FieldRef Name="Link_x0020_Filename" />

至少这就是为我解决问题所需要的。希望有帮助!

关于sharepoint - 为什么 <ViewFields> 条件会被 SharePoint 列表服务的 GetListItems 方法忽略,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3248000/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com