navigating xPath in field changed event using C# - InfoPath Dev
in

InfoPath Dev

Use our Google Custom Search for best site search results.

navigating xPath in field changed event using C#

Last post 07-05-2012 10:41 AM by Hilary Stoupa. 1 replies.
Page 1 of 1 (2 items)
Sort Posts: Previous Next
  • 07-05-2012 06:09 AM

    navigating xPath in field changed event using C#

    I'm using InfoPath 2007 to create a browser form.  In the form I have a Contact Selector.  When it changes I want to get the value of the AccountID and set another field and run additional code. The xpath of the Contact Selector node that my changed event is triggered from is:

    /my:myFields/my:gpAuthor/my:gpContactSelector/my:Person/my:AccountId

     I'd like to set this field:

     /my:myFields/my:Debug

    To get the current fields value I'm using:

    String author = e.Site.Value;

    I've tried the following to set Debugs value but none of them seem to work:

    1. e.Site.SelectSingleNode("/my:myFields/my:Debug", NamespaceManager).SetValue(author)

    2. e.Site.MoveToRoot();

        e.Site.SelectSingleNode("/my:myFields/my:Debug", NamespaceManager).SetValue(author);

    3. e.Site.SelectSingleNode("../../my:Debug", NamespaceManager).SetValue(author);

    4. e.Site.SelectSingleNode("../../../my:Debug", NamespaceManager).SetValue(author);

    5. e.Site.SelectSingleNode("../../../../my:Debug", NamespaceManager).SetValue(author);

    6. e.Site.SelectSingleNode(",,/,,/,,/../../my:Debug", NamespaceManager).SetValue(author);

    How is this supposed to be done?

    Thanks,

     Dave

  • 07-05-2012 10:41 AM In reply to

    Re: navigating xPath in field changed event using C#

    Since this is a node outside any repeating group, I'd probably just use:

    this.MainDataSource.CreateNavigator().SelectSingleNode("/my:myFields/my:Debug", NamespaceManager).SetValue(author);

    Hilary Stoupa

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