使用ECMA从SharePoint欢迎页面查询两个不同列表时出现问题

trouble querying 2 different lists from a SharePoint welcome page using ECMA

本文关键字:两个 列表 问题 SharePoint ECMA 查询 使用      更新时间:2023-09-26

我的方法在这里不起作用。我在SharePoint 2010文档集的欢迎页面上,并已将我的脚本放置在内容编辑器Web部件CEWP中。使用以下代码,我得到了一个jquery/javascript块。我可以从两个不同的代码块中获得一组或另一组值,但不能同时获得。因此,我在两个查询中复制了一些代码行,这似乎会导致冲突,但我不确定我可以更改什么来使两个集合都是唯一的,或者两者之间发生了什么冲突。非常感谢任何指导。我现在只是在兜圈子。谢谢-dave

我使用的两个块看起来像这样,但在listName上不同。也许这个页面只能支持其中一个?

         $(document).ready(function () {
        $().SPServices({
            operation: "GetListItems",
            async: false,
            CAMLRowLimit: 2000,                
            listName: "Personnel Management",
            completefunc: fnCallBack
        });
    });

    function fnCallBack(xData, Status) {
        var index = 0;
        $documentListtable = $("#documentListtable");
        //Navigate through the XML
        $(xData.responseXML).find("z'':row, row").each(function () {

    //Get the values to a local variable
            var _url = $(this).attr("ows_FileRef").split(";#")[1];
            var _name = $(this).attr("ows_LinkFilename");
       ;
            var _author = $(this).attr("ows_Editor").split(";#")[1];
            var modifiedOn = $(this).attr("ows_Modified");
            var _TrainingStatus = $(this).attr("ows_Training_x0020_Certificates");


            //Create clone of the table row
            var $row = $("#templates").find(".row-template").clone();
            //Add values to the column based on the css class
            $row.find(".DocumentName").html(_pdfLink);
            $row.find(".Author").html(_author);
            $row.find(".LastModifiedOn").html(modifiedOn);
            $row.find(".TrainingStatus").html(_TrainingStatus);

            //Change the style for even rows
            if (index % 2 == 0) {
                $row.addClass("jtable-row-even")
            }

     if (_TrainingStatus.indexOf("1001") !=-1)
      {
       index = index + 1;
            //add the row to table
            $documentListtable.append($row);
           }
                    - 

您可以尝试在一个$(document).ready中添加两个SPServices调用,而不是在两个$(document).ready块中添加。一个页面中可能有多个$(document).ready,但您的问题听起来像是在页面加载时只触发了一个SPService调用。