Xpath on Repeating table - preceding-sibling - InfoPath Dev
in

InfoPath Dev

Xpath on Repeating table - preceding-sibling

Last post 09-17-2014 07:48 AM by Hilary Stoupa. 10 replies.
Page 1 of 1 (11 items)
Sort Posts: Previous Next
  • 05-07-2013 07:12 AM

    • MattyG
    • Not Ranked
    • Joined on 05-07-2013
    • Posts 6

    Xpath on Repeating table - preceding-sibling

    Hello. Sorry if the information for my question is already posted but I am new to Infopath (2007) and the examples I have found in the threads do not solve my issue...

    I have a repeating table binding to a SharePoint list. I am trying to hide rows where values repeat on different rows. I have used the preceding-sibling xpath function but I cannot get it to work.

    The data source is:

    RiskAssessments (Secondary)  -  myFields\dataFields\RiskAssessments

    Columns  -  Title,  RiskNo,  LineNumber,  RAVersion,  Year,  Division,  Site,  Department,  DepartmentArea

    Where the "RiskNo" on one row is the same as the "RiskNo" on the row above, i would like to hide the row.  I have tried:

    ../preceding-sibling::@RiskNo

    But get a "Node-test expected." error.

    Any help would be appreciated.

    Thank you.

    Matt

     

  • 05-07-2013 07:29 AM In reply to

    Re: Xpath on Repeating table - preceding-sibling

     So - the rule is on RiskAssessments? Is the XPath  myFields\dataFields\RiskAssessments one that you got by right clicking the repeating group and selecting Copy XPath in the data source task pane? I'm wondering about namespace prefixes.

    Generally, if you don't have any namespace prefixes and the rule is on RiskAssessments, I'd think you'd want the expression:

    @RiskNo = preceding-sibling::RiskAssessments/@RiskNo

    Or - select RiskNo in the first drop down of the condition, "is equal to" in the second drop down and "use a formula" in the third drop down, with the formula being preceding-sibling::RiskAssessments/@RiskNo

    If your data source has namespace prefixes tho, this XPath will be incorrect and will need those added - preceding-sibling::dfs:RiskAssessments/@d:RiskNo, for example.

    Hilary Stoupa

  • 05-07-2013 12:00 PM In reply to

    • MattyG
    • Not Ranked
    • Joined on 05-07-2013
    • Posts 6

    Re: Xpath on Repeating table - preceding-sibling

    Hi Hilary.

    Thank you very much for your reply.

    Yes the rule is on RiskAssessments.

    I still cannot get it right !

    When I tried using the expression: "@RiskNo = preceding-sibling::dfs:myFields/dfs:dataFields/dfs:RiskAssessments/@RiskNo", there was no errors but it did not hide any of the repeating rows.

    When I tried the formula by selecting RiskNo in the dropdown, then equals to "preceding-sibling::/dfs:myFields/dfs:dataFields/dfs:RiskAssessments/@RiskNo", I get the same error that "Node-test expected.".

    I then try removing the "/" before "dfs:myFields", but then the error this "does not point to a valid location path of a field or group." appears. I tried selecting the RiskNo field but still no good.

    Any more help would be appreciated. Thank you.

  • 05-07-2013 12:21 PM In reply to

    Re: Xpath on Repeating table - preceding-sibling

     Mind attaching your form under the Options tab in a reply? I can take a quick look later today...

    Hilary Stoupa

  • 05-07-2013 01:09 PM In reply to

    • MattyG
    • Not Ranked
    • Joined on 05-07-2013
    • Posts 6

    Re: Xpath on Repeating table - preceding-sibling

    Attached as requested.

    Thanks for your help.

  • 05-07-2013 02:51 PM In reply to

    Re: Xpath on Repeating table - preceding-sibling

     Okay - you were using a full path instead of a relative path - try this one. Save it locally, right click, select design and then you can preview and see if this does what you need.

    Hilary Stoupa

  • 05-07-2013 11:13 PM In reply to

    • MattyG
    • Not Ranked
    • Joined on 05-07-2013
    • Posts 6

    Re: Xpath on Repeating table - preceding-sibling

    Yes that worked great, thank you.

    Just one question though, how did you select the relative path?

    I've tried to do the same in other tables for other fields but I get the "does not point...." error again ! I've tried selecting the fields and typing the fields but no good.

    Thank you.

  • 05-08-2013 08:05 AM In reply to

    Re: Xpath on Repeating table - preceding-sibling

     I manually typed in the formula. If you change the first dropdown to "the expression" you can see what the actual XPath is.

    Hilary Stoupa

  • 09-15-2014 06:31 PM In reply to

    Re: Xpath on Repeating table - preceding-sibling

    Hi,

    I have a repeating table to is connected to a PharePoint list and i am attempting to apply a rule where I only want to show the last record entered for a particular item (this item will have many records associated with it) I'm trying to do similar to what is in this post http://www.infopathdev.com/forums/p/25793/89568.aspx but when i use preceding-sibling this does not work for me. If i use preceding as in this example: coursetitle = preceding::d:coursetitle this works perfect however when i try to publish this form it causes the memory and cpu usage to max out on the server and the entire environment slows to a crawl affecting all users and the publishing process freezes.

     Can you assist? Thanks.   

  • 09-17-2014 06:56 AM In reply to

    Re: Xpath on Repeating table - preceding-sibling

    Hi so after a couple long nights I eventually got preceding-sibling to work. I used preceding-sibling::d:SharePointListItem_RW/d:coursetitle. Now I'm trying to do some conditional formatting put a count of records actually displayed on the page. In total there are 427 records returned and after I apply this rule:. d:coursetitle = preceding-sibling::d:SharePointListItem_RW/d:coursetitle it hides some rows, so now I'm trying to figure out how to put a count of records not hidden on the page for the user to see. Any ideas?

     Thanks much for your response 

  • 09-17-2014 07:48 AM In reply to

    Re: Xpath on Repeating table - preceding-sibling

    Put a calculated value where you want the count of all the displayed records to be and select the repeating SharePointListItem_RW group in the formula editor. Then click "Edit XPath" and paste the XPath in a reply and I'll give you a hand. :)

    Good job on figuring out the preceding-sibling formula - your form will publish now, right?

    Hilary Stoupa

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