Deleting a Row in a Repeating Table - InfoPath Dev
in

InfoPath Dev

Deleting a Row in a Repeating Table

Last post 02-28-2014 06:51 AM by Zoidy. 6 replies.
Page 1 of 1 (7 items)
Sort Posts: Previous Next
  • 02-27-2014 05:46 AM

    • Zoidy
    • Not Ranked
      Male
    • Joined on 10-01-2008
    • London
    • Posts 4

    Deleting a Row in a Repeating Table

     Hi,

     I know this has been asked before and I have looked at the answers on those but I am still not getting anywhere.

    I would like to delete a row from a repeating table with two different methods:

    a.) Delete the same row where a user clicks on an image button in that row.

    b.) Delete rows (on submit) where a specific field is empty or zero.

    The following command will delete all the rows in the table so I know this at least works:

    Delete /xpath=/dfs:myFields/dfs:dataFields/d:ExpensesMain/d:ExpenseItems

    But I have tried ...

    concat("Delete /xpath=/dfs:myFields/dfs:dataFields/d:ExpensesMain/d:ExpenseItems/[@ReceiptNumber = '", 0, "']")

    concat("Delete /xpath=/dfs:myFields/dfs:dataFields/d:ExpensesMain/d:ExpenseItems/[ReceiptNumber='", 0, "']")

    concat("Delete /xpath=/dfs:myFields/dfs:dataFields/d:ExpensesMain/d:ExpenseItems/[d:ReceiptNumber='", 0, "']")

    concat("Delete /xpath=/dfs:myFields/dfs:dataFields/d:ExpensesMain/d:ExpenseItems/[", count(preceding-sibling::/d:ExpenseItems) + 1 , "]")

    This is the xpath for the field I am testing this with:

    /dfs:myFields/dfs:dataFields/d:ExpensesMain/d:ExpenseItems/@ReceiptNumber

    The form is an InfoPath Filler form.

    Cheers,

    Pete.

     

  • 02-27-2014 06:15 AM In reply to

    Re: Deleting a Row in a Repeating Table

    You just need to delete the slashes before the predicates (the parts in [square brackets]):

    Delete /xpath=/dfs:myFields/dfs:dataFields/d:ExpensesMain/d:ExpenseItems[@ReceiptNumber = 0]   (no concat() needed here)

    concat("Delete /xpath=/dfs:myFields/dfs:dataFields/d:ExpensesMain/d:ExpenseItems[", count(preceding-sibling::d:ExpenseItems) + 1 , "]")

    Jimmy Rishe / Software Developer / Microsoft MVP
    Qdabra Software
  • 02-27-2014 07:16 AM In reply to

    • Zoidy
    • Not Ranked
      Male
    • Joined on 10-01-2008
    • London
    • Posts 4

    Re: Deleting a Row in a Repeating Table

    Many thanks Jimmy,  the first one works beautifully.

    However the second one is still not doing anything I'm afraid.

  • 02-27-2014 07:24 AM In reply to

    Re: Deleting a Row in a Repeating Table

     Ah, sorry, you need to remove the / after preceding-sibling:: (I imagine InfoPath displayed some sort of error about that?).  Fixed it now.

    Jimmy Rishe / Software Developer / Microsoft MVP
    Qdabra Software
  • 02-28-2014 12:01 AM In reply to

    • Zoidy
    • Not Ranked
      Male
    • Joined on 10-01-2008
    • London
    • Posts 4

    Re: Deleting a Row in a Repeating Table

     Hi Jimmy,

     That line still doesn't work for me. I'm not getting an error either way.  Any other ideas?

    Cheers,

    Pete.

  • 02-28-2014 06:32 AM In reply to

    Re: Deleting a Row in a Repeating Table

    For the second one, you need to open up the Formula Editor and enter it there, not in the Value: box. Is that where you're entering it?

    Note that you can also troubleshoot by dragging the qRules Error field into your form and seeing what it says after you execute a command.

    Jimmy Rishe / Software Developer / Microsoft MVP
    Qdabra Software
  • 02-28-2014 06:51 AM In reply to

    • Zoidy
    • Not Ranked
      Male
    • Joined on 10-01-2008
    • London
    • Posts 4

    Re: Deleting a Row in a Repeating Table

     Ahhh, was entering it into the Value box!  Doh!.

    However, I have now pasted the line into the Formula Editor and put the error field onto the view and I'm getting this error:

    Action: Delete. Arguments: xpath: /dfs:myFields/dfs:dataFields/d:ExpensesMain/d:ExpenseItems/[2] . Details: Expression must evaluate to a node-set.

     

    UPDATE:

    Ignore that error.  I re-pasted in the line from your reply above, after ticking Edit Xpath (advanced) and it now works great.

    Many thanks for your help.

    Cheers,

    Pete.

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