Ok i think i've solved my own problem (haven't thoroughly tested it but it seems to work so far):
function XDocument::OnSubmitRequest(eventObj)
{
// If the submit operation is successful, set
// eventObj.ReturnStatus = true;
var objDOMNode; // stores a node in the DOM
var objNamedNodeMap; // stores a collection of node attributes
var objADOAdapter; // data adapter used to connect to the database
var objDOMNodeList; // stores a list of DOM nodes
var strSQLInsert; // stores an SQL insert statement
var objDBConn; // connection to the MS SQL database
// create a DOM Node List to put all the author nodes into
try
{
objDOMNodeList = XDocument.DOM.selectNodes("/dfs:myFields/dfs:dataFields//d:authors2");
}
catch(ex)
{
XDocument.UI.Alert("Could not create XMLDOMNodeList object.\r\n"
+ ex.number + " - " + ex.description);
// Return with eventObj.ReturnStatus == false (the default value)
return;
}
// get the ADO data adapter for the database connection
objADOAdapter = XDocument.QueryAdapter;
// create a new database connection
objDBConn = new ActiveXObject("ADODB.Connection");
// get the connection string
objDBConn.ConnectionString = objADOAdapter.Connection;
// open the connection
objDBConn.Open();
// loop through all the records to find the ones that have the resubmit field checked
while( objDOMNode = objDOMNodeList.nextNode() )
{
// get the attribute list for the current DOM Node
objNamedNodeMap = objDOMNode.attributes;
// <DEBUGGING>
//XDocument.UI.Alert("objNamedNodeMap.getNamedItem(\"submit\"): " + objNamedNodeMap.getNamedItem("submit").xml);
// </DEBUGGING>
// Filter out the records that are to be submitted to the database
if( objNamedNodeMap.getNamedItem("submit").nodeValue == "True" )
{
// store the attributes of the current node
ln = objNamedNodeMap.getNamedItem("lname").nodeValue;
fn = objNamedNodeMap.getNamedItem("fname").nodeValue;
addr = objNamedNodeMap.getNamedItem("address").nodeValue;
// if the string value is False assign 0 to avoid conversion problems when submitting to the database
contract = ( (objNamedNodeMap.getNamedItem("contract").nodeValue == "False")? 0 : 1 );
// always set to 0 so that when queries are run none of the records will have a check mark in the submit field
// which could lead to new records being submitted by mistake
submit = 0;
strSQLInsert = "INSERT INTO authors2(lname,fname,address,contract,submit) VALUES(" +
"'"+ln+"'" + "," + "'"+fn+"'" + "," + "'"+addr+"'" + "," + contract + "," + submit + ")";
//strSQLInsert = "execute addNewRecord " + "'"+ln+"'" + "," + "'"+fn+"'" + "," + "'"+addr+"'" + "," + contract + "," + submit;
objADOAdapter.Command = strSQLInsert;
// <DEBUGGING>
XDocument.UI.Alert("SQL command: " + objADOAdapter.Command);
// </DEBUGGING>
try
{
// query the data source
objDBConn.Execute(strSQLInsert);
}
catch(ex)
{
XDocument.UI.Alert("Error executing insert query.\r\n"
+ ex.number + " - " + ex.description);
// Return with eventObj.ReturnStatus == false (the default value)
return;
}
} // END-IF
} // END-WHILE
// close the database connection
objDBConn.Close();
// set eventObj.ReturnStatus = true
eventObj.ReturnStatus = true;
XDocument.UI.Alert("Submit was successful!");
}
The only thing i haven't gotten it to do is after submitting to open a new blank form like how you can specify this in the form submit options dialog (without using code).