Clear a single field in Repeating table in changed event of a field in same repeating table. - InfoPath Dev
in

InfoPath Dev

Having trouble finding a blog or post that answers your question? Check out our Custom Search Page

Clear a single field in Repeating table in changed event of a field in same repeating table.

Last post 09-11-2014 01:07 PM by mcharnell. 5 replies.
Page 1 of 1 (6 items)
Sort Posts: Previous Next
  • 02-28-2010 08:41 PM

    • Aditya
    • Top 150 Contributor
      Female
    • Joined on 01-26-2010
    • Sydney
    • Posts 59

    Clear a single field in Repeating table in changed event of a field in same repeating table.

    Hi,

     

    I have a repeating table in my infopath form.I would like to know is there a way to clear a single field in one instance of repating table.Because if i clear one field using a rule or code,it is applying to all instances of repeating table. 

    Aditya,
    .Net programmer.
  • 02-28-2010 11:01 PM In reply to

    Re: Clear a single field in Repeating table in changed event of a field in same repeating table.

    it is possible to clear a particular instance of a field in repeating table using code.

    XPathNodeIterator listItemNav = this.MainDataSource.CreateNavigator().Select("my repeating table path", this.NamespaceManager);

    for (int i = 0; i < listItemNav.Count; i++)

    {

    listItemNav.MoveNext();

     //condition for which you want to clear

    listItemNav.Current.SelectSingleNode("field_name", this.NamespaceManager).SetValue(string.Empty());

    }

    Qazi Anis
    System Analyst
    Bitwise Solutions
  • 03-01-2010 03:01 PM In reply to

    • Aditya
    • Top 150 Contributor
      Female
    • Joined on 01-26-2010
    • Sydney
    • Posts 59

    Re: Clear a single field in Repeating table in changed event of a field in same repeating table.

     Hi Qazi,

    Thanks for your reply.I tried to do the same as you guided.It is clearing the field.But not the field related to that Repeating table instance.Clearing the field of the first instance only.

    Public Sub CRFH_ISBN1_Changed(ByVal sender As Object, ByVal e As XmlEventArgs)

    ' Write your code here to change the main data source.

    Dim path As XPathNodeIterator = MainDataSource.CreateNavigator().Select("/my:ContractRequest/my:Titles/my:Details/my:ISBNDetails", Me.NamespaceManager)

    'path.SelectSingleNode("/my:ContractRequest/my:Titles/my:Details/my:ISBNDetails/my:CRFH_Title1", Me.NamespaceManager).SetValue("")

    Dim i As Integer

    For i = 0 To path.Count

    path.MoveNext()

    path.Current.SelectSingleNode(
    "/my:ContractRequest/my:Titles/my:Details/my:ISBNDetails/my:CRFH_Title1", Me.NamespaceManager).SetValue(String.Empty)

    Next

    End Sub

    Aditya,
    .Net programmer.
  • 03-01-2010 03:28 PM In reply to

    • Aditya
    • Top 150 Contributor
      Female
    • Joined on 01-26-2010
    • Sydney
    • Posts 59

    Re: Clear a single field in Repeating table in changed event of a field in same repeating table.

    Hi all,For this thread this is the code i figured out working well.Thanks again qazi.

    Public Sub SelectCustomer_Changed(
       ByVal sender As Object, ByVal e As XmlEventArgs)
       Try
          ' Get a reference to the Customers secondary data source,
          ' and create an XPathNavigator object for it.
          Dim Customers As XPathNavigator = _
             Me.DataSources("Customers").CreateNavigator

          ' Create an XPathNavigator object positioned on the current site,
          ' which is the SelectCustomer node in the main data source.
          Dim myForm As XPathNavigator = e.Site.CreateNavigator

          ' Move to the parent of the SelectCustomer node, so that the code
          ' can access the CustomerName node.
          myForm.MoveToParent()

          ' Check if the user selected the blank value from the
          ' Drop-Down List Box after previously selecting a CustomerID.
          If e.Site.InnerXml = "" Then
             ' Clear previously selected value from CustomerName field.
             myForm.SelectSingleNode("my:CustomerName", _
                Me.NamespaceManager).DeleteSelf()
          Else
             ' Get the Company name from the Customers data source using
             ' the value in the CustomerID node.
             Dim custName As String = Customers.SelectSingleNode( _
                "/Customers/Customer[CustomerID = '" & e.Site.InnerXml & _
                "']/CompanyName", Me.NamespaceManager).InnerXml

             ' Select the CustomerName node for the current row
             ' and set its value.
             myForm.SelectSingleNode("my:CustomerName", _
                Me.NamespaceManager).SetValue(custName)
           End If
       Catch ex As Exception
          MessageBox.Show("Error: " & ex.Message)
       End Try
    End Sub

    Aditya,
    .Net programmer.
  • 03-01-2010 09:46 PM In reply to

    Re: Clear a single field in Repeating table in changed event of a field in same repeating table.

    Public Sub CRFH_ISBN1_Changed(ByVal sender As Object, ByVal e As XmlEventArgs)

    ' Write your code here to change the main data source.

    Dim path As XPathNodeIterator = MainDataSource.CreateNavigator().Select("/my:ContractRequest/my:Titles/my:Details/my:ISBNDetails", Me.NamespaceManager)

    'path.SelectSingleNode("/my:ContractRequest/my:Titles/my:Details/my:ISBNDetails/my:CRFH_Title1", Me.NamespaceManager).SetValue("")

    Dim i As IntegerFor i = 0 To path.Count

    path.MoveNext()

    path.Current.SelectSingleNode("my:CRFH_Title1", Me.NamespaceManager).SetValue(String.Empty)

    Next

    you needed to give the relative path, you were giving the full path

    Qazi Anis
    System Analyst
    Bitwise Solutions
  • 09-11-2014 01:07 PM In reply to

    • mcharnell
    • Not Ranked
    • Joined on 08-01-2014
    • Vancouver, BC
    • Posts 2

    Re: Clear a single field in Repeating table in changed event of a field in same repeating table.

     This is fantastic.  Thank you

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