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;
}
}
{
// 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;
}
}
相关文章推荐
- Add a logo from a SharePoint library to an InfoPath browser form
- Using SharePoint Web Services to Fill Out an InfoPath Form
- How to upload a file to SharePoint from an InfoPath form
- How to use document library in Sharepoint 2010
- Error message when you try to modify or to delete an alternate access mapping in Windows SharePoint Services 3.0: "An update conflict has occurred, and you must re-try this action"
- How to change service accounts and service account passwords in SharePoint Server 2007 and in Windows SharePoint Services 3.0
- How to submit data in InfoPath form services
- 转:How to submit the rows of a repeating table in InfoPath to a SharePoint list
- How to change service accounts and service account passwords in SharePoint Server 2007 and in Windows SharePoint Services 3.0
- How to enable search function of Windows SharePoint Services
- SharePoint2013 IT Professional - Publish InfoPath Form to SharePoint Library
- How to change service accounts and service account passwords in SharePoint Server 2007 and in Windows SharePoint Services 3.0(Se
- How to set Item Level Permission for SharePoint 2007 (MOSS/WSS) List/Document Library Programmatically
- [转贴]How to work with stored procedures by using script in an Office InfoPath 2003 form
- How to Clone an Infopath Form 如何复制一个新的 eForm/Infopath Form ?
- Switch view in the InfoPath form according to the whether current user is in SharePoint group admin
- Windows SharePoint Services To Be Open Source With 2007 Microsoft Office Release
- [转]Writing Custom Entries to the Audit Log in Windows SharePoint Services 3.0(如何记录自定义审核日志)
- Windows SharePoint Services 3.0 "Visual How Tos" 视频系列
- Uploading files to the SharePoint Document Library and updating any metadata columns