用于根据不适用于其他用户的特定字段的值在SharePoint项目上显示错误的代码

时间:2013-08-28 18:06:24

标签: javascript sharepoint sharepoint-2010

以下代码应在用户点击某个项目时显示错误提醒:

// when "reserve" link is clicked, do this stuff
$("a.reserve").live("click",function(){
    listID = $(this).attr("class").split(" ")[1];
    itemID = $(this).attr("class").split(" ")[2];
    status = checkReservationStatus(listID, itemID);
    duplicate = checkDuplicateReservation(listID);
    // if (duplicate == "no") {
        if (status == "Open") {
            openReservationForm(listID,itemID);
        } else {
            alert("Sorry...it's been taken! Try another time.");
            getSelectedTeachers();
        }
    // } else if (duplicate == "yes") {
    //  alert("Sorry, you can't reserve more than 1 time slot.");
        getSelectedTeachers();
    //}
});

这是应该确定项目的状态字段是打开还是关闭的代码:

function checkReservationStatus (listID, itemID) {
$().SPServices({
    operation: "GetListItems",
    webURL: myListURL,
    async:false,
    listName: listID,
    // get list name from passed variable lisTitle
    CAMLViewFields: "<ViewFields><FieldRef Name='ID' /><FieldRef Name='Status' /></ViewFields>",
    CAMLQuery:"<Query><Where><Eq><FieldRef Name='ID' /><Value Type='Integer'>" + itemID + "</Value></Eq></Where></Query>",
    completefunc: function (xData, Status) {
        $(xData.responseXML).SPFilterNode("z:row").each(function(){
            status = $(this).attr("ows_Status");
        })
    }
})
if(status == "Closed") {
    return "Closed";
} else {
    return "Open";
}
} // end function checkReservationStatus

该程序对我来说很好。但是,其他用户(对关联列表具有完全控制权限)会在每个项目上收到错误消息,无论项目的状态字段是打开还是关闭。有什么想法吗?

0 个答案:

没有答案