hmmm...option #1 is unclear to me...you mean create additional fields in the
database to 'hold' the values I want and repopulate the form with these after
submit? Seems like a lot of work and wasted space
#2 How to key it to a different trigger? 2nDairy data source is connected to
a DDLB...
Here is my code...notice the fileds in question
@CustomerNum,@CustAddr1,@CustAddr2,@CustAddr3,@CustZIP..any way to 'mark/set'
a property on the field when I write to it to make it think I entered the
data manually?
/*
* 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: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-24T18:16:36"');
//</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/@CustomerNum
// 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.
// Get the DOM for the Seconday Data Source
var dat = XDocument.DataObjects("CustomerInfo").DOM;
var ns =
"xmlns:dfs='http://schemas.microsoft.com/office/infopath/2003/dataFormSolution'
xmlns:d='http://schemas.microsoft.com/office/infopath/2003/ado/dataFields\'";
dat.setProperty("SelectionNamespaces", ns);
// Get the value of the selected item in the dropdown list
var sVariable =
getNodeValue("/dfs:myFields/dfs:dataFields/d:tblRAHeader/@CustName");
// Get the node from the Seconday Data Source using the value from the
dropdown list
var xNode =
dat.selectSingleNode("/dfs:myFields/dfs:dataFields/d:vwCustomerInfo_basic[@Name='" + sVariable + "']");
// If the value is not null (shouldn't be but j.i.c.)
if (xNode == null)
{
setNodeValue("/dfs:myFields/dfs:dataFields/d:tblRAHeader/@CustomerNum", "");
setNodeValue("/dfs:myFields/dfs:dataFields/d:tblRAHeader/@CustAddr1", "");
setNodeValue("/dfs:myFields/dfs:dataFields/d:tblRAHeader/@CustAddr2", "");
setNodeValue("/dfs:myFields/dfs:dataFields/d:tblRAHeader/@CustAddr3", "");
setNodeValue("/dfs:myFields/dfs:dataFields/d:tblRAHeader/@CustZIP", "");
}
else
// Set the values in the form DOM using the values from the Seconday Data
Source DOM
{
setNodeValue("/dfs:myFields/dfs:dataFields/d:tblRAHeader/@CustomerNum",
xNode.selectSingleNode("@Customer").text);
setNodeValue("/dfs:myFields/dfs:dataFields/d:tblRAHeader/@CustAddr1",
xNode.selectSingleNode("@Address1").text);
setNodeValue("/dfs:myFields/dfs:dataFields/d:tblRAHeader/@CustAddr2",
xNode.selectSingleNode("@Address2").text);
setNodeValue("/dfs:myFields/dfs:dataFields/d:tblRAHeader/@CustAddr3",
xNode.selectSingleNode("@Address3").text);
setNodeValue("/dfs:myFields/dfs:dataFields/d:tblRAHeader/@CustZIP",
xNode.selectSingleNode("@Zip").text);
}
}
/*
=============================================================================
Node value operations
============================================================================= */
/*------------------------------------------------------------------------------
isInvalidOrEmpty()
------------------------------------------------------------------------------*/
function isInvalidOrEmpty(xmlNode)
{
// If there is no value, ignore it.
if (!xmlNode || !xmlNode.text)
return true;
// The caller can pass additional error types as optional arguments.
var aErrorTypes = new Array;
if (arguments.length > 1)
{
for (var i=1; i<arguments.length; i++)
aErrorTypes.push(arguments[i]);
}
else
{
aErrorTypes.push("SCHEMA_VALIDATION");
}
// If there is a validation error related to this node,
// then the node is invalid.
for (var i=0; i<XDocument.Errors.Count; i++)
{
var oError = XDocument.Errors(i);
if (xmlNode == oError.Node)
{
for (var j in aErrorTypes)
{
if (oError.Type == aErrorTypes[j])
return true;
}
}
}
// Is valid (no error was found).
return false;
}
/*------------------------------------------------------------------------------
getNodeValue()
------------------------------------------------------------------------------*/
function getNodeValue(xpath, defaultValue)
{
var xmlNode = getNode(xpath);
if (isInvalidOrEmpty(xmlNode))
return (arguments.length > 1) ? defaultValue : "";
else
return xmlNode.text;
}
/*------------------------------------------------------------------------------
getNode()
------------------------------------------------------------------------------*/
function getNode(xpath)
{
// Both XML node and absolute XPath are allowed.
if (typeof(xpath) == "string")
return XDocument.DOM.selectSingleNode(xpath);
else
return xpath;
}
/*------------------------------------------------------------------------------
setNodeValue()
------------------------------------------------------------------------------*/
function setNodeValue(xpath, value)
{
var xmlNode = getNode(xpath);
if (!xmlNode)
return;
// Setting the value would mark the document as dirty.
// Let's do that if the value has really changed.
if (xmlNode.text != value)
xmlNode.text = value;
}
> BFSMith
>
[quoted text clipped - 20 lines]
> > fields after I submit...I want the field data to remain viewable after I
> > submit???
BFSmith - 28 Feb 2006 15:37 GMT
I changed my code to populate one of the fields in question with a string of
"123456" (not from secondary data source) and the field still went blank
after submit...this must have to do with programmatically setting a field -
not the secondary data source...so it seems that saving the values off to
temporary storage wont work either...what a pain...
> hmmm...option #1 is unclear to me...you mean create additional fields in the
> database to 'hold' the values I want and repopulate the form with these after
[quoted text clipped - 206 lines]
> > > fields after I submit...I want the field data to remain viewable after I
> > > submit???