Delete rows in a repeating table that satisfy certain criterion - InfoPath Dev
in

InfoPath Dev

Use our Google Custom Search for best site search results.

Delete rows in a repeating table that satisfy certain criterion

Last post 01-20-2010 11:42 AM by ricomarcelo. 5 replies.
Page 1 of 1 (6 items)
Sort Posts: Previous Next
  • 11-01-2009 10:29 PM

    Delete rows in a repeating table that satisfy certain criterion

    Hello,

    I have a form with one button and one repeating table (Table1).  The repeating table has textbox and date controls.  My data source is

    Table1

         Textbox1

         Date1

     

    I am using VB script. I want to creat a code that, when I click on the button, will DELETE some rows from the repeating table if they satisfy a certain criterion (or criteria) like

        * Textbox1 = "this"

        * Textbox1 = 1

        * Date1 = "4/5/2009"

        * Date1 is before three days ago

        * Textbox1 = 1    AND   Date1="3/5/2009"

     

    Thank you in advance for your help.

    Khaled

    Filed under: , ,
  • 11-02-2009 08:08 PM In reply to

    Re: Delete rows in a repeating table that satisfy certain criterion

    The code would be something like this:

    Dim rowList
    Set rowList = XDocument.DOM.selectNodes("/my:myFields/my:group1/my:group2")

    For Each row In rowList
         Dim field1Value
         field1Value = row.selectSingleNode("my:field1").text
         Dim field2Value
         field2Value = row.selectSingleNode("my:field2").text
        
         ' Add your field value checks here 
         If (field1Value = "7") or (field1Value = "hello" and field2Value = "2") Then 
              row.parentNode.removeChild(row) 
         End If
    Next

    You'll naturally need to use your own appropriate XPath and conditional logic.

     

    Jimmy Rishe / Software Developer / Microsoft MVP
    Qdabra Software
  • 11-03-2009 01:14 AM In reply to

    Re: Delete rows in a repeating table that satisfy certain criterion

    Thank you very much for the xample.  It worked for me.

  • 12-22-2009 11:17 AM In reply to

    Re: Delete rows in a repeating table that satisfy certain criterion

    Hi guys,

    I was trying out a jscript version of the code above to delete all rows in my repeating table. So I came up with the following code unfortunately I'm getting an error message:

    var rowList = XDocument.DOM.selectNodes("/dfs:myFields/dfs:dataFields/d:tblMaster/d:tblDetail");

    for (var row in rowList)

    {

    row.parentNode.removeChild(row);

    }

    Can anybody point out what I'm missing? Thanks

  • 12-23-2009 02:28 PM In reply to

    Re: Delete rows in a repeating table that satisfy certain criterion

    Hi:

    I'm betting you haven't replaced a sample xpath in the code sample with your own xpath. Where the code sample says:

    "/dfs:myFields/dfs:dataFields/d:tblMaster/d:tblDetail"

    you need to put in the xpath to your own repeating group. Are you using InfoPath 2003 or 2007? If you are using 2007, you may want to consider using VSTA and managed code rather than jscript. If you need help figuring out the xpath to your repeating group, you can post a screenshot of your Main data source with the folders expanded to show the group you want to delete rows from.

    You can attach a file to your reply post under the Options tab.

     

    Hilary Stoupa

  • 01-20-2010 11:42 AM In reply to

    Re: Delete rows in a repeating table that satisfy certain criterion

    I'm sorry I didn't realize I got a response for my post on this thread. I have to search through my older posts to see it. Anyways, thanks Hilary... I already found a fix for the said problem.

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