简体   繁体   English

从Sharepoint页面上的列表中获取字段

[英]Getting fields from a list on Sharepoint page

I'm very new to Sharepoint, I have an aspx page on a Sharepoint site that shows a list of fields, including First Name, Last Name, etc. I'm have a console app, in Visual Studio, I'm using for testing communication and data transfer capability between between one web service and another; 我是Sharepoint的新手,Sharepoint网站上有一个aspx页面,其中显示了字段列表,包括名字,姓氏等。我在Visual Studio中有一个控制台应用程序,我正在使用测试一个Web服务与另一个Web服务之间的通信和数据传输能力; namely Sharepoint and another web service. 即Sharepoint和另一个Web服务。 My goal is to populate the various fields in the list on my Sharepoint site with data from the other web service. 我的目标是用来自其他Web服务的数据填充Sharepoint网站上列表中的各个字段。 I'm using a web reference to the Lists Web Service on my Sharepoint server to try and gain access to fields in this particular list on the Sharepoint site. 我正在使用对Sharepoint服务器上的Lists Web服务的Web引用,以尝试访问Sharepoint网站上此特定列表中的字段。 I have the following code: 我有以下代码:

''Name of my web reference to Lists Web Service is "sharepoint"
        Dim sharepointList As New sharepoint.Lists()
        sharepointList.Credentials = System.Net.CredentialCache.DefaultCredentials

        Dim testLists As XmlNode = sharepointList.GetListCollection
        Dim xmlText As String = testLists.InnerXml
        Dim xmlElement As XmlAttributeCollection = testLists.Attributes

I've been trying to find where this particular list is. 我一直在尝试查找此特定列表的位置。 I'll admit I'm not sure where I'm supposed to be looking, as the above code demonstrates. 我承认,如上面的代码所示,我不确定应该去哪里。 I've been using the debugger to analyze each of the above variables to try and find where in the XML this particular list is defined. 我一直在使用调试器来分析上述每个变量,以尝试查找此特定列表在XML中的定义位置。 Any help or insight is appreciated. 任何帮助或见解表示赞赏。

Here is a snapshot of the Sharepoint page containing the list I'm trying to search for: 这是Sharepoint页面的快照,其中包含我要搜索的列表:

替代文字

UPDATE: 更新:

I decided to use the GetList() function and passed the name "New Hires" to it. 我决定使用GetList()函数,并将名称“ New Hires”传递给它。 It ended up grabbing the list above. 最后,它抓住了上面的列表。 Now I'm just trying to see if I can get access to just the fields pictured above, analyzing the xml it seems like those are just display names, the actual fieldID is some alpha numeric string, ie Display Name = "Business Phone" has the Field ID = "{fd630629-c165-4513-b43c-fdb16b86a14d}". 现在,我只是想看看是否可以访问上图所示的字段,分析xml似乎只是显示名称,实际的fieldID是一些字母数字字符串,即Display Name =“ Business Phone”具有字段ID =“ {fd630629-c165-4513-b43c-fdb16b86a14d}”。 I'm wondering if there's a way to search fields by Display Name. 我想知道是否有一种通过显示名称搜索字段的方法。

It's a two-pronged approach. 这是两个方面的方法。

First, you need to access the SharePoint service from the context of the particular site that your list resides in. For example, if the URL to your list was: 首先,您需要从列表所在的特定网站的上下文访问SharePoint服务。例如,如果列表的URL是:

http://sharepoint/foo/bar/baz/Lists/MyList http:// sharepoint / foo / bar / baz / Lists / MyList

You would access the List Web Service from: http://sharepoint/foo/bar/baz/_vti_bin/lists.asmx 您可以从以下网址访问列表Web服务: http://sharepoint/foo/bar/baz/_vti_bin/lists.asmx

Now you're in the correct site collection. 现在,您在正确的网站集中。 The remaining step would be to specify the list via name or GUID when you call one of the List methods. 剩下的步骤将是在调用List方法之一时通过名称或GUID指定列表。 For example, if you were calling the UpdateListItems method (and it sounds like you will be), you'd use: 例如,如果您正在调用UpdateListItems方法(听起来像是),则可以使用:

sharepoint.UpdateListItems( "{B1DC8A9C-2316-41AD-875B-01C9D4BD19F8}", myUpdateXml );

or 要么

sharepoint.UpdateListItems( "MyList", myUpdateXml );

Obviously, list name will correspond to the actual list name you see in the list's URL. 显然,列表名称将与您在列表的URL中看到的实际列表名称相对应。 The GUID can be found by viewing the list in SharePoint, then navigating to Settings > List Settings and grabbing it from the URL (look for the List querystring parameter). 可以通过以下方式找到GUID:在SharePoint中查看列表,然后导航到“设置”>“列表设置”,然后从URL中获取它(查找“ List querystring”参数)。 It will be encoded, but you can use a utility like URL Decoder/Encoder to decode it to a proper GUID. 它将被编码,但是您可以使用URL Decoder / Encoder之类的实用程序将其解码为适当的GUID。 Be sure to remember to use the {} brackets when sending in the GUID as a parameter. 在将GUID作为参数发送时,请务必记住使用{}括号。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM