B
BFSmith
I keep having trouble with this...I cant seem to get a nonNull reference to
my secondary data...all is well (presumably) until the next to last line of
code...always returns a null reference...anybody care to debug?
/*
* This file contains functions for data validation and form-level events.
* Because the functions are referenced in the form definition (.xsf) file,
* it is recommended that you do not modify the name of the function,
* or the name and number of arguments.
*
*/
// The following line is created by Microsoft Office InfoPath to define the
prefixes
// for all the known namespaces in the main XML data file.
// Any modification to the form files made outside of InfoPath
// will not be automatically updated.
//<namespacesDefinition>
XDocument.DOM.setProperty("SelectionNamespaces",
'xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:q="http://schemas.microsoft.com/office/infopath/2003/ado/queryFields"
xmlns:d="http://schemas.microsoft.com/office/infopath/2003/ado/dataFields"
xmlns:dfs="http://schemas.microsoft.com/office/infopath/2003/dataFormSolution"
xmlns:my="http://schemas.microsoft.com/office/infopath/2003/myXSD/2006-02-21T03:22:17" xmlns:xd="http://schemas.microsoft.com/office/infopath/2003"');
XDocument.GetDOM( "vwCustomerInfo_basic" ).setProperty(
"SelectionNamespaces" ,
'xmlns:d0="http://schemas.microsoft.com/office/infopath/2003/ado/dataFields"
' );
//</namespacesDefinition>
//=======
// The following function handler is created by Microsoft Office InfoPath.
// Do not modify the name of the function, or the name and number of
arguments.
// This function is associated with the following field or group (XPath):
/dfs:myFields/dfs:dataFields/d:tblRAHeader/@CustName
// Note: Information in this comment is not updated after the function
handler is created.
//=======
function msoxd__tblRAHeader_CustName_attr::OnAfterChange(eventObj)
{
// Write code here to restore the global state.
if (eventObj.IsUndoRedo)
{
// An undo or redo operation has occurred and the DOM is read-only.
return;
}
// A field change has occurred and the DOM is writable. Write code here to
respond to the changes.
// Retrieve the vwCustomerInfo_basic secondary data source
// Retrieve the SQL statement of the data source
// (the DOM of the vwCustomerInfo_basic Data Object)
var customerInfoAuxDom = XDocument.DataObjects("vwCustomerInfo_basic").DOM
XDocument.UI.Alert(customerInfoAuxDom == null);
customerInfoAuxDom.setProperty("SelectionNamespaces",
'xmlns:d0="http://schemas.microsoft.com/office/infopath/2003/ado/dataFields"');
var strSQL =
XDocument.DataObjects["vwCustomerInfo_basic"].QueryAdapter.Command;
XDocument.UI.Alert(strSQL);
var strCustName = eventObj.NewValue;
XDocument.UI.Alert(eventObj.NewValue);
// Generate the new SQL statement with WHERE clause
strSQL += " where vwCustomerInfo_basic.Name = ' " + strCustName + " '";
XDocument.UI.Alert(strSQL);
// Populate the command with the new SQL statement
XDocument.DataObjects["vwCustomerInfo_basic"].QueryAdapter.Command = strSQL;
// Run the query
XDocument.DataObjects["vwCustomerInfo_basic"].Query();
XDocument.UI.Alert("Query has been run");
// Find the Customer in the secondary data source and the CustomerNum in
the main data source
var customerAuxNode = customerInfoAuxDom.selectSingleNode(
"/d0:myFields/d0:Customer"); <<<<====== returns TRUE-ie null ref...namespace
issue?
XDocument.UI.Alert(customerAuxNode == null);
var strCustomer = customerAuxNode.text;
XDocument.UI.Alert(strCustomer);
// Update the main data source with the queried value;
// Populate XML document with customer information.
}
my secondary data...all is well (presumably) until the next to last line of
code...always returns a null reference...anybody care to debug?
/*
* This file contains functions for data validation and form-level events.
* Because the functions are referenced in the form definition (.xsf) file,
* it is recommended that you do not modify the name of the function,
* or the name and number of arguments.
*
*/
// The following line is created by Microsoft Office InfoPath to define the
prefixes
// for all the known namespaces in the main XML data file.
// Any modification to the form files made outside of InfoPath
// will not be automatically updated.
//<namespacesDefinition>
XDocument.DOM.setProperty("SelectionNamespaces",
'xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:q="http://schemas.microsoft.com/office/infopath/2003/ado/queryFields"
xmlns:d="http://schemas.microsoft.com/office/infopath/2003/ado/dataFields"
xmlns:dfs="http://schemas.microsoft.com/office/infopath/2003/dataFormSolution"
xmlns:my="http://schemas.microsoft.com/office/infopath/2003/myXSD/2006-02-21T03:22:17" xmlns:xd="http://schemas.microsoft.com/office/infopath/2003"');
XDocument.GetDOM( "vwCustomerInfo_basic" ).setProperty(
"SelectionNamespaces" ,
'xmlns:d0="http://schemas.microsoft.com/office/infopath/2003/ado/dataFields"
' );
//</namespacesDefinition>
//=======
// The following function handler is created by Microsoft Office InfoPath.
// Do not modify the name of the function, or the name and number of
arguments.
// This function is associated with the following field or group (XPath):
/dfs:myFields/dfs:dataFields/d:tblRAHeader/@CustName
// Note: Information in this comment is not updated after the function
handler is created.
//=======
function msoxd__tblRAHeader_CustName_attr::OnAfterChange(eventObj)
{
// Write code here to restore the global state.
if (eventObj.IsUndoRedo)
{
// An undo or redo operation has occurred and the DOM is read-only.
return;
}
// A field change has occurred and the DOM is writable. Write code here to
respond to the changes.
// Retrieve the vwCustomerInfo_basic secondary data source
// Retrieve the SQL statement of the data source
// (the DOM of the vwCustomerInfo_basic Data Object)
var customerInfoAuxDom = XDocument.DataObjects("vwCustomerInfo_basic").DOM
XDocument.UI.Alert(customerInfoAuxDom == null);
customerInfoAuxDom.setProperty("SelectionNamespaces",
'xmlns:d0="http://schemas.microsoft.com/office/infopath/2003/ado/dataFields"');
var strSQL =
XDocument.DataObjects["vwCustomerInfo_basic"].QueryAdapter.Command;
XDocument.UI.Alert(strSQL);
var strCustName = eventObj.NewValue;
XDocument.UI.Alert(eventObj.NewValue);
// Generate the new SQL statement with WHERE clause
strSQL += " where vwCustomerInfo_basic.Name = ' " + strCustName + " '";
XDocument.UI.Alert(strSQL);
// Populate the command with the new SQL statement
XDocument.DataObjects["vwCustomerInfo_basic"].QueryAdapter.Command = strSQL;
// Run the query
XDocument.DataObjects["vwCustomerInfo_basic"].Query();
XDocument.UI.Alert("Query has been run");
// Find the Customer in the secondary data source and the CustomerNum in
the main data source
var customerAuxNode = customerInfoAuxDom.selectSingleNode(
"/d0:myFields/d0:Customer"); <<<<====== returns TRUE-ie null ref...namespace
issue?
XDocument.UI.Alert(customerAuxNode == null);
var strCustomer = customerAuxNode.text;
XDocument.UI.Alert(strCustomer);
// Update the main data source with the queried value;
// Populate XML document with customer information.
}