0

大家好,
我正在使用具有四种内容类型的 SharePoint 2007 日历。

  1. 标准会议
  2. Skype 会议
  3. 电话会议
  4. 聊天会议

我正在使用 JQuery 1.4.2。

我正在尝试在日历页面上为提前不到 72 小时安排的 Skype 会议创建警报弹出窗口。如果在 URL 中传递了“SkypeError=1”,我会在日历页面中内置警报以显示。

现在我正在尝试让 Ne​​wForm.aspx 识别已选择 Skype 会议内容类型并显示错误。在 PreSaveAction 函数中,我有一个警报显示 ContentTypeId 正在被识别,另一个警报显示选择了哪个动态 URL。然后在 setOnSubmitRedir 函数中,我有一个警报,显示相同的 URL 已传递给它,另一个警报显示完整的 url 已针对提交按钮进行了修改。

在日历中添加 Satandard 会议时,一切正常。但是,如果我选择任何其他内容类型,则只有取消按钮有效。如果我按提交,我会得到通用的 MOSS2007“发生意外错误。 ”考虑到我可以看到正确的信息正在传递,这很奇怪。另外,当我查看错误页面的 URL 时,我会在那里看到:
https://myURL/myPortal/Lists/ConfRes/NewForm.aspx?RootFolder=%2fmyPortal%2fLists%2fConfRes&Source=/myPortal/Pages/MeetingCalendar.aspx?SkypeTime=yes

我尝试从动态重定向中删除“ ?SkypeTime=yes ”,认为“ ? ”可能会导致问题。
保存内容时,一切似乎都失败了。收到错误时永远不会保存内容。当我从页面中删除代码时,提交适用于所有内容类型。

非常感谢和需要帮助。任何有关如何测试从开始时间不到 72 小时内添加的事件的帮助也非常感谢。

代码是使用 CEWP 添加的。我没有服务器权限来启用更多可靠的错误或查看日志。

<script type="text/javascript" src="/94thaamdc/SiteCollectionCode/jquery-1.4.2.min.js">
//Load JQuery
</script>

<script type="text/javascript">
// Where to go when cancel is clicked on the form
goToWhenCanceled = '/myPortal/Pages/MeetingCalendar.aspx';
// Edit the redirect on the cancel-button's
$('.ms-ButtonHeightWidth[id$="GoBack"]').each(function(){
    $(this).click(function(){
            STSNavigate(goToWhenCanceled);
      })
});

// Function to determine the dynamic URL for the OnSubmit-redirect.
// This function is automatically executed before saving the item.
function PreSaveAction(){
// The URL is determined by the ContentTypeId located in the URL of the content type link.
// Grab the ContentTypeId from the content type link's URL and save it to a local
// variable called contentTypeId.
var contentTypeId = querySt("ContentTypeId");
// Assign a dynamic redirect URL to the function by setting it here
// based on contentTypeId from the URL.
    if(contentTypeId=='0x010...'){
        var dynamicRedirect = '/myPortal/Pages/MeetingCalendar.aspx?SkypeError=1';
    }else{
        var dynamicRedirect = '/myPortal/Pages/MeetingCalendar.aspx';
    }
    // Alerts are just to watch what's going on in the code. Remove when done testing.
    alert("1. contentTypeId:  "+contentTypeId);
    alert("2. dynamicRedirect:  "+dynamicRedirect);
    // Call the function and set the redirect URL in the form-action attribute
    setOnSubmitRedir(dynamicRedirect);
    // This function must return true for the save item to happen
    return true;
}

//Function to parse the ContentTypeId from the URL string
function querySt(stKey) {
    stQString = window.location.search.substring(1);
    arKeyValues = stQString.split("&");
    for (i = 0; i < arKeyValues.length; i++) {
        arPairs = arKeyValues[i].split("=");
        if (arPairs[0] == stKey) {
            return arPairs[1];
        }
    }
};

// Function to edit the form-action attribute to add the source=yourCustomRedirectPage
function setOnSubmitRedir(redirURL){
var action = $("#aspnetForm").attr('action');
var end = action.indexOf('&');
    if(action.indexOf('&')<0){
        newAction = action + "?Source=" + redirURL;
    }else{
        newAction = action.substring(0,end) + "&Source=" + redirURL;
    }
$("#aspnetForm").attr('action',newAction);
// Test to see if the URL was passed correctly. Remove when done testing.
alert("3. redirURL:  "+redirURL);
// Test to see if the new URL is properly formatted. Remove when done testing.
alert("4. newAction:  "+newAction);
}
</script>
4

1 回答 1

0

由于我无法弄清楚为什么重定向不起作用,我选择了另一条不需要它的路径。不过,我仍然想知道最初的尝试有什么问题。我需要改进弹出的实际警告框,但下面的代码运行良好。该警告仅针对进入事件的人显示,并且每次他们进入日历时都会显示,直到他们在 72 小时前进入新事件。

<script type="text/javascript" language="javascript" src="/myPortal/jquery.1.4.2.min.js"></script>
<script type="text/javascript" language="javascript" src="/myPortal/jquery.SPServices-0.7.2.min.js"></script>
<script type="text/javascript" language="javascript">
/*
Name:           EventTimeLimit
Developer:      RogueVeggie
Version - Date: v1 - 20130207

Purpose:        Test if a Skype meeting has been added less than 72 hours prior to 
                the actual meeting time in a SharePoint Calendar.
                A warning displays if this is the last event entered by the user.

Prerequisite:   Create a Content Type called "Skype Meeting".
                In the SharePoint calendar Create a Calculated column called Skype72hrTest.
                Paste the following script into it:

                IF([Content Type]="Skype Meeting",IF([Sit Down Time]-Created>=3,"Pass","Fail"),"NA")

                Add this code to a Content Editor Web Part at the bottom of your SharePoint 
                Calendar page.
                Set the web part Chrome to "None".
                Don't hide the web part or the warning won't display.
*/

var taskListName = "MYGUID12-3456-7890-ASDF-GHJKLZXCVBNM" // This is the GUID of the list we want to query.
var lastId = $().SPServices.SPGetLastItemId({ 
    listName: taskListName 
}); // This gets the ID of the last event added by the current user.
var testQuery = "<Query><Where><Eq><FieldRef Name='ID' /><Value Type='Text'>"+lastId+"</Value></Eq></Where></Query>"; // This is our CAML Query string.
var divWarn = "<DIV style='Z-INDEX: 999; POSITION: absolute; PADDING-BOTTOM: 25px; BACKGROUND-COLOR: #800505; PADDING-LEFT: 25px; WIDTH: 743px; PADDING-RIGHT: 25px; HEIGHT: 175px; COLOR: white; FONT-SIZE: 150%; TOP: 55%; FONT-WEIGHT: 900; PADDING-TOP: 25px; LEFT: 22.38%' id='VTCWarn'><DIV style='FONT-SIZE: 200%'>WARNING:</DIV><DIV>Skype scheduling requires 72 hour notice to register.<BR>Please contact IT.</DIV></DIV>";//This is the warning message

$(document).ready(function() {
  $().SPServices({
    operation: "GetListItems",
    async: false,
    listName: taskListName ,
   CAMLRowLimit: 1,
    CAMLQuery: testQuery,
    CAMLViewFields: "<ViewFields><FieldRef Name='Skype72hrTest' /></ViewFields>",// Skype72hrTest is a calculated column in the calendar to test if the event was added less than 72 hours before the Skype meeting.
    completefunc: function (xData, Status) {
        $(xData.responseXML).SPFilterNode("z:row").each(function() {
            var passFail = $(this).attr("ows_Skype72hrTest");// Skype72hrTest stores the result in a string as "Pass", "Fail", or "NA".

            if (passFail === "string;#Fail"){// Tests to see if the string Fail is in the Skype72hrTest column
                $("#Warning").append(divWarn);
            }
        });
    }
  });
});
// The below DIV is needed so we have a place to put the warning when passFail=Fail.
</script>
<div id='Warning'></div>
于 2013-02-08T02:56:32.453 回答