Need help with preceding-sibling - InfoPath Dev
in

InfoPath Dev

Need help with preceding-sibling

Last post 04-08-2015 06:43 AM by Jimmy. 11 replies.
Page 1 of 1 (12 items)
Sort Posts: Previous Next
  • 04-02-2015 01:27 PM

    Need help with preceding-sibling

    Hi All:

     I have a pepeater table and trying to copy the previous row to the new row once a user clicks 'add new row'.

    My approach is to set up a formular for each column as default value.

     Here is my field structure:

    - myFields

    -- my:FootprintGrp

    ----- Field1

    ----- Field2

     So I opened Field1 and added the following formula as a default value:

    ../preceding-sibling::my:my:FootprintGrp/@Field1

     I always receive Validation Errors.

     Can someone point me to the right direction ?

     

    thanks,

    Mike

     

  • 04-02-2015 02:07 PM In reply to

    Re: Need help with preceding-sibling

    Right click Field1 in the main data source task pane and select copy XPath - is it really an attribute? Paste the XPath in a reply and I can help you out.

    Hilary Stoupa

  • 04-02-2015 02:49 PM In reply to

    Re: Need help with preceding-sibling

    Thank you Hilary.

    So here is the actual example xpath of a field from the repeater table:

     /dfs:myFields/my:FootprintGrp/my:FootprintCommRate

    Earlier I just used Field1 but it actually is FootprintCommRate.

    Thank you so much in advance

    Mike

  • 04-02-2015 02:59 PM In reply to

    Re: Need help with preceding-sibling

    Okay, so if you want to set FootprintCommRate to the preceding value:

    ../preceding-sibling::my:FootprintGrp/my:FootprintCommRate

    Hilary Stoupa

  • 04-02-2015 03:41 PM In reply to

    Re: Need help with preceding-sibling

    awesome. it works like a charm.

     Bets of all, I know now how the syntax goes.

    Thanks so much Hilary.

  • 04-02-2015 03:47 PM In reply to

    Re: Need help with preceding-sibling

    You bet, glad that helped - for more, you may want to take a look at this: http://zvon.org/xxl/XPathTutorial/Output/example16.html

    Hilary Stoupa

  • 04-06-2015 11:23 AM In reply to

    Re: Need help with preceding-sibling

    Hi Hilary,

     do you mind if I ask for help one more time ?

     Everything is working in the filler but once deployed as web form the fields behave strange. For example when I select a dropdown value in the repeating table it jumps back to blank immediately. I assume this is because it is the first row in the table and preceding row does not exist.

     

    How would you work around that problem?

    thank you!!

  • 04-06-2015 11:38 AM In reply to

    Re: Need help with preceding-sibling

    I might have found the solution myself.

    I turned off "refresh value when formula is recalculated" and it seems to start working as expected.

    is that how to do it?

    thanks again

  • 04-06-2015 11:40 AM In reply to

    Re: Need help with preceding-sibling

    Maybe instead of using this as a default, you could add a rule to the repeating group to set the field to the preceding sibling. Then when the row is inserted, the field gets set.... But if turning off refresh works for you, that's great too. :)

    Hilary Stoupa

  • 04-06-2015 11:50 AM In reply to

    Re: Need help with preceding-sibling

    good idea. Might go that route if I run into other problems with the default value.

     

    thanks again Hilary

  • 04-07-2015 10:57 AM In reply to

    Re: Need help with preceding-sibling

    Hi Hilary,

    You seem like the expert with xpath so I have one more question for you.

    The following will give me the value of field AmendVerNum of first row.

    AmendmentGrp[1]/AmendVerNum

     How can I get the value of the last row ?

    thanks again

  • 04-08-2015 06:43 AM In reply to

    Re: Need help with preceding-sibling

    Hi Mozzak,

    The XPath for that would be

    AmendmentGrp[last()]/AmendVerNum

    If you're using a browser form and it doesn't like the use of last(), then this one will probably work:

    AmendmentGrp[not(following-sibling::my:AmendmentGrp)]/AmendVerNum

    Jimmy Rishe / Software Developer / Microsoft MVP
    Qdabra Software
Page 1 of 1 (12 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.