Repeating section - display data for the current selection - InfoPath Dev
in

InfoPath Dev

Repeating section - display data for the current selection

Last post 11-11-2010 05:45 AM by Anne Maciejewski. 4 replies.
Page 1 of 1 (5 items)
Sort Posts: Previous Next
  • 11-04-2010 05:12 AM

    Repeating section - display data for the current selection

    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

  • 11-05-2010 09:40 PM In reply to

    Re: Repeating section - display data for the current selection

    HI, ur values are not getting saved because of repeating section properties, every time when page gets refreshed, the values are set to null. What you need to do is , create clone of first row of repeating table and then insert values into it, save those values in parameters and then repeat the same procedure, but every time pass the parameter values to the fields in repeating section if the no of rows in repeating section is more than 1. Try this, it has worked for me in the past and i hope for u too it will work..

    Vishal Srivastava
    Senior Software Engineer
    SDG Software Pvt Ltd
  • 11-11-2010 02:50 AM In reply to

    Re: Repeating section - display data for the current selection

    Hi, thanks for your reply.

    I am struggling to understand what you mean - would you be able to give me some more information on how I go about this? I have found how to clone the row but I am not sure what to do next (i.e. save values in parameters and pass parameter values to the fields - how do I do this??).

     Many thanks

     Anne

  • 11-11-2010 05:24 AM In reply to

    Re: Repeating section - display data for the current selection

    Try this method

    private void AddMethodNode(int id, string cmd, XPathNavigator curNode, string[] strFieldNames, string[] strFieldValues) { System.Text.StringBuilder sb = new System.Text.StringBuilder(); sb.AppendFormat("", id.ToString(), cmd); for (int index = 0; index < strFieldNames.Length; index++) { string fieldValue = string.Empty; if (curNode != null) fieldValue = curNode.SelectSingleNode(strFieldValues[index], namespaceManager).Value; else fieldValue = strFieldValues[index]; sb.AppendFormat("{1}", strFieldNames[index], fieldValue); } sb.AppendFormat(""); XmlDocument methodXML = new XmlDocument(); methodXML.LoadXml(sb.ToString()); XPathNavigator secDSNav = DataSources["BatchSubmitTemplate"].CreateNavigator(); XPathNavigator batchNav = secDSNav.SelectSingleNode("/Batch", namespaceManager); batchNav.AppendChild(methodXML.DocumentElement.CreateNavigator()); }

    here id will be equal to 1, cmd is either "new" or "update". current node is "rows.current" if you are using iter.movenext to iterate repeating table rows, 'strfieldnames' would be field names in form and 'strfieldvalues' will be values from sharepoint. BatchSubmittemplate is the xml data source, you can create your own xml file with this data. Add this xml file as your secondary datasource file. This works for me. Hope it would run for u too. let me know if you face some problem..

    <?xml version="1.0" encoding="UTF-8" ?>

    - <Batch>
    - <Method ID="1" Cmd="New">
      <Field Name="Title" />
      </Method>
    - <Method ID="2" Cmd="New">
      <Field Name="Title" />
      </Method>
      </Batch>
    Vishal Srivastava
    Senior Software Engineer
    SDG Software Pvt Ltd
  • 11-11-2010 05:45 AM In reply to

    Re: Repeating section - display data for the current selection

    I am using jscript in InfoPath 2003 (I can't therefore use C#) - is there a jscript version of this?

    Thanks

    Anne

Page 1 of 1 (5 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.