Hi - hoping someone can help me - I am sure this should be straighforward but it is proving to be a headache.
I am using InfoPath 2003 SP3.
I have a form with a repeating section within which is a dropdown list (populated from a secondary data source) from which a user selects the name of a property (apartment).
Having selected the property, I want some other fields in the section to populate with data about the selected property from the same secondary data source.
My problem is that although the first section works fine, any subsequent sections display the data relating to the property selected in the first section e.g.
User selects "property_1", category displayed is "sheltered".
User inserts a record and selects "property_2", category displayed is still "sheltered", it should be "extra care".
Having read many posts/blogs on this theme it would seem I need to utilise the current() method but however I try I cannot get this to work. This post http://www.infopathdev.com/forums/p/7169/26292.aspx#26292 seems to provide a solution but I have tried every variation suggested and nothing works - indeed instead of displaying an incorrect category, it doesn't display the category at all in either the first section or any subsequest sections. Is this due to the version I am on?
I have also tried to set these fields using code (jscript) in an OnAfterChange event attached to the dropdown list...this is my code...
function msoxd_my_property_ref::OnAfterChange(eventObj) { if (eventObj.IsUndoRedo || eventObj.NewValue == null) { return; } if (eventObj.Operation == "Insert") { var propertyRef = eventObj.NewValue; // for testing - check the property ref is correct XDocument.UI.Alert("property is " + propertyRef);
//query the secondary data source to get the additional data according to the selected property
loadPropertyData(propertyRef);
//set node values
//reference to the field on my form I want to populate
var propertyCategoryNode = XDocument.DOM.selectSingleNode("/my:myFields/my:scheme_data/my:property_data/my:p_category"); //reference to the data required in the secondary data sourcevar propertyCategory = XDocument.GetDOM("PROPERTY_DATA").selectSingleNode("/dfs:myFields/dfs:dataFields/d:DIM_PROPERTY[@PROPERTY_REFERENCE = '" + propertyRef + "']/@PROPERTY_TYPE_DESCRIPTION").text; //assign the content of the secondary data source to the field in my formpropertyCategoryNode.text = propertyCategory; } function loadPropertyData(propertyRef) {
//pass the selected property into the where clause
var whereClause = "PROPERTY_REFERENCE = '" + propertyRef + "'\n"; //query the secondary data sourceexecuteAdapterQuery("PROPERTY_DATA", whereClause);
}
a summary of my schema is as follows:
my:Fields
- my:scheme_data
- some scheme fields here
- my:property_data (repeating group)
- my:property_ref
- my:p_category
- other property data fields here
Any help would be much appreciated!
Thanks
Anne