使用SharePoint SOAP使用jQuery GetListItems - 简单,但不能工作了! [英] Using SharePoint SOAP with jQuery GetListItems - Simple but can't work it out!

查看:136
本文介绍了使用SharePoint SOAP使用jQuery GetListItems - 简单,但不能工作了!的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在SharePoint列表加载到一个无序列表,所以我可以创建一个简单的搜索功能(SharePoint搜索仅仅是可怕的)。在code我借和调整是如下:

I'm trying to load in a SharePoint list to a Unordered List so I can create a simple search function (the Sharepoint Search is just horrible). The code I have borrowed and adapted is below:

$(document).ready(function() {
        var soapEnv =
            "<soapenv:Envelope xmlns:soapenv='http://schemas.xmlsoap.org/soap/envelope/'> \
                <soapenv:Body> \
                     <GetListItems xmlns='http://schemas.microsoft.com/sharepoint/soap/'> \
                        <listName>Metric_Audit</listName> \
                        <viewFields> \
                            <ViewFields> \
                <FieldRef Name='ReportName' /> \
                <FieldRef Name='Metric Name' /> \
                           </ViewFields> \
                        </viewFields> \
                    </GetListItems> \
                </soapenv:Body> \
            </soapenv:Envelope>";

        $.ajax({
            url: "http://teamspace.intranet.group/sites/CSI/ID/DB/_vti_bin/lists.asmx",
            type: "POST",
            dataType: "xml",
            data: soapEnv,
            complete: Result,
            contentType: "text/xml; charset=\"utf-8\""
        });
    });


    function Result(xData, status) {
        $(xData.responseXML).find("z\\:row").each(function() {
            var liHtml = "<li>" + $(this).attr("ows_ReportName") + "</li>";
            $("#MetricsUL").append(liHtml);
        });
    }
});

<ul id="MetricsUL"/> 

据填充列表,因为它应该,但所有项目的名称为未定义。我试图去掉空格等无济于事,当我改变列表的任务列表中它工作得很好。

It populates the list as it should but all the items have the name 'undefined'. I have tried removing spaces etc. to no avail and when I change the list to the 'tasks' list it works just fine.

一直盯着这个的年龄。你可以建议任何提示将是真正的AP preciated!我敢肯定,这是小东西,我只是不能工作了!

Been staring at this for AGES. Any tips you can suggest would be really appreciated! I'm sure it's something small that I just can't work out!

谢谢!

推荐答案

你有没有验证你引用正确的字段名称?

Have you verified you're referencing the correct Field names?

您在 soapEnv 所定义的CAML查询需要使用域'的的内部的名称,而不是他们的显示名称。我保证公制名称是不正确的;它可能像 Metric_x0020_Name 或类似的。

The CAML query you've defined in soapEnv requires the use of the fields' internal names, not their display names. I guarantee Metric Name is not right; it's probably something like Metric_x0020_Name or similar.

你如何确定你的域的内部名称?有一对夫妇的方法。

How do you determine the internal names of your fields? There's a couple of methods.

让我给你介绍一个伟大的工具叫的 U2U CAML查询生成器的。这应该是每个SharePoint开发人员的工具箱。火起来,在右侧列表指向它(通过SharePoint Web服务连接,如果你不是在服务器上),它可以让你使用的字段的显示名称建立CAML查询,但生成正确的基础CAML的您。它也非常适合构建复杂的过滤器和布尔逻辑,再加上它可以让你运行查询,并得到即时的反馈。

Let me introduce you to a great utility called U2U CAML Query Builder. This should be in every SharePoint developer's toolbox. Fire it up, point it at the right list (connect via SharePoint Web Service if you're not on the server), and it will allow you to build CAML queries using the display names of the fields, but generate the correct underlying CAML for you. It's also great for constructing complex filters and boolean logic, plus it lets you run the query and get immediate feedback.

另一种方式来获得字段名是导航到列表设置,然后点击你感兴趣的一个字段的名称。看看您的网址和查找名为查询参数&放;现场;它会泄露该字段的内部名称。此值将URL连接codeD,如果您正在使用Internet Explorer(一个简单的在线德codeR 可以帮助破译的值),但是如果你使用的是Firefox,你会看到的价值unen $ C $光盘。

Another approach to getting the field name is to navigate into the list settings, then click on the name of a field you're interested in. Check out your URL and look for the querystring parameter named &Field; it will divulge the internal name of the field. This value will be URL Encoded if you're using Internet Explorer (a simple online decoder can help decipher the value), but if you use Firefox, you'll see the value unencoded.

插入正确的字段名称到您的CAML查询,并给它一个旋转。

Plug the correct Field names into your CAML query and give it another whirl.

这篇关于使用SharePoint SOAP使用jQuery GetListItems - 简单,但不能工作了!的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆