您的位置:首页 > 运维架构

How to submit an InfoPath form to a Windows SharePoint Services document library

2005-04-05 10:17 537 查看
function XDocument::OnSubmitRequest(eventObj)
{
    // If the submit operation is successful, set
    // eventObj.ReturnStatus = true.
    var fSuccessful = false;

    // Set the URL of the file that you want to submit here.
    var strUrl = "http://ServerName/SiteName/DocumentLibraryName/testform.xml";

    try
    {
        // Create an xmlhttp object.
        var oXmlHttp = new ActiveXObject("MSXML2.XMLHTTP");

        // See whether the document with the same name already exists in the Windows SharePoint Services (WSS) document library.
        oXmlHttp.Open("HEAD", strUrl, false);
        oXmlHttp.Send();

        //  No document with the URL has been found. Continue to submit.
        // If you must replace the original file, you must call
        // oXmlHttp.Open("DELETE", strUrl, false) to delete the document
        // in the WSS document library.
        if (oXmlHttp.Status == 404)
        {
            // Put the document in the WSS document library.
            oXmlHttp.Open("PUT", strUrl, false);
            oXmlHttp.Send(XDocument.DOM.xml);

            //  A 200 status code or a 201 status code indicates that the form has been submitted successfully.
            if (oXmlHttp.Status == 200 || oXmlHttp.Status == 201)
            {
                fSuccessful = true;
            }
        }
    }
    catch (ex){}

    if (fSuccessful)
    {
        XDocument.UI.Alert("Document submitted successfully.");
        eventObj.ReturnStatus = true;
    }
    else
    {
        eventObj.ReturnStatus = false;
    }
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
相关文章推荐