So, how do you do it then? I'll need an example probably.
:
BFSmith
I currently DONT use code to do this in upwards of 4 or 5 forms that are
currently in use. Which is why i mentioned it
:
That doesnt make much sense to me...notice my <= pointer to a problem...I
think I have other problems also...here is the codse so far:
function msoxd__tblRAHeader_CustomerNum_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
// (the DOM of the vwCustomerInfo_basic Data Object)
//var producPriceAuxDom = XDocument.DataObjects("vwCustomerInfo_basic").DOM;
var vwCustomerInfo_basicAuxDom =
XDocument.DataObjects("vwCustomerInfo_basic").DOM;
// Retrieve the SQL statement of the data source
var strSQL =
XDocument.DataObjects["vwCustomerInfo_basic"].QueryAdapter.Command;
XDocument.UI.Alert(strSQL);
// Retrieve the field in the InfoPath form whose value will be used in the
WHERE clause
var node = XDocument.DOM.selectSingleNode("/my:myFields/my:CustomerNum");
XDocument.UI.Alert(node == null); //<= returns true..field name is
CustomerNum???????
XDocument.UI.Alert(node.text);
// Generate the new SQL statement with WHERE clause
strSQL += " where tblRAHeader.CustomerNum = ' " + node.text + " '";
// Populate the command with the new SQL statement
XDocument.DataObjects["vwCustomerInfo_basic"].QueryAdapter.Command = strSQL;
// Run the query
XDocument.DataObjects["vwCustomerInfo_basic"].Query();
// Find the price in the secondary data source and the main data source
var CustomerNameAuxNode =
vwCustomerInfo_basicAuxDom.selectSingleNode("vwCustomerInfo_basic:Name");
var CustomerNameFormNode = eventObj.Site.selectSingleNode("../my:CustName");
// Update the main data source with the queried value;
CustomerNameFormNode.text = CustomerNameAuxNode.text;
}
:
I don't think you need code. Just add your main datasource back in as a
secondary datasource and populate the drop-down list with customer number and
use filtering to also show the correct name.
Job done.
Cheeres Adam
:
I have a Returns Authorization form that has Customer info in it
(CustNumber,CustName,Address1, etc) in the main data source. I have a
secondary data source (CustomerMaster) that I would like to use a dropdown
list box to select the proper Customer Number (It's be nice to display the
Number & Name in the dropdown) and map those fields into the Main data
source. I think I've read that I need to use code attached to the drop down
field on the OnAfterChange event. Any examples?