How to traverse from an errors object to its parent node (using C#)? - InfoPath Dev
in

InfoPath Dev

Use our Google Custom Search for best site search results.

How to traverse from an errors object to its parent node (using C#)?

Last post 09-29-2010 06:44 AM by Alf Kiil. 3 replies.
Page 1 of 1 (4 items)
Sort Posts: Previous Next
  • 09-23-2010 04:09 AM

    How to traverse from an errors object to its parent node (using C#)?

    I am trying to implement an “errors page” (a separate view) in InfoPath browser-enabled forms, because users often find it difficult to locate errors in multiple view  and complex forms. An errors page may also facilitate more and better information/links to resources/guidance on errors than mouse over info allows for.I am extensively using referenced groups/fields, where a repeating group may be used in different views but for different purposes/to allow for a different functionality, as illustrated below.

    VIEW 1 (used for the applicant company):
    <my:CompanyGroup>
      <my:CompanyTable>
        <my:CompanyId></my:CompanyId>
        <my:CompanyName></my:CompanyName>
        <my:CompanyAddress></my:CompanyAddress>
        <my:CompanyZip></my:CompanyZip>
        … etc   
      </my:CompanyTable>
    </my:CompanyGroup> 

    VIEW2 (used for partner companies):
    <my:CompanyGroup2>
      <my:CompanyTable> (reference repeating group of CompanyTable above)
        <my:CompanyId></my:CompanyId>
        <my:CompanyName></my:CompanyName>
        <my:CompanyAddress></my:CompanyAddress>
        <my:CompanyZip></my:CompanyZip>
        … etc   
      </my:CompanyTable>
    </my:CompanyGroup2> 

    I use the FormError properties to locate the errors, and display them in an errors list on the errors page, where I also want to indicate the particular view where the error occurs. However, these properties (Site.LocalName, Site.OuterXml.ToString) only allows me to identify the immediate node, and not the parent node (example: err.Site.LocalName on an error in CompanyZip only identifies the node name “CompanyZip”). Because the same node may occur in different referenced groups in different views, I am not able to guide the user to which view the error occurs (is it in View 1 or View 2?). So my question is, how do I traverse from the particular error object (e.g. CompanyZip) to its parent (first to CompanyTable, then to CompanyGroup)?

  • 09-24-2010 01:28 AM In reply to

    Re: How to traverse from an errors object to its parent node (using C#)?

    Hi Alf Kiil,

    We implemented this several years ago and have a working sample for both rich client and browser forms. I will ask one of our developers to respond to your specific question tomorrow.

    More soon,

    Patrick Halstead
    Project Manager at Qdabra
  • 09-24-2010 08:30 AM In reply to

    Re: How to traverse from an errors object to its parent node (using C#)?

    Hi Alf,

    Site is just an XPathNavigator node, so you treat it like any other and use Site.SelectSingleNode(".."); to get the parent node. Or if you know that your XML structure is always going to start with a node named "my:CompanyTable" then you can traverse back using Site.SelectSingleNode("ancestor::my:CompanyTable/..").LocalName to access the group node name.

  • 09-29-2010 06:44 AM In reply to

    Re: How to traverse from an errors object to its parent node (using C#)?

    Hi guys,

    It works.

    By the way. In my particular case, I was looking for the top level nodes where the names of the nodes varies (i.e. they don't always start with "my:CompanyTable"). The solution that works for me is simply:

    string topNode = err.Site.SelectSingleNode("../..").LocalName.ToString();

    Thanks!

     

     

     

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