Get/set value of repeating section - InfoPath Dev
in

InfoPath Dev

Get/set value of repeating section

Last post 11-30-2010 01:56 AM by denfer06. 4 replies.
Page 1 of 1 (5 items)
Sort Posts: Previous Next
  • 11-29-2010 01:45 AM

    Get/set value of repeating section

    Hello

    I didn't find a solution to my issue after several search in this forum, perhaps I didn't type the correct keywords.

    here is my issue:

    I have 2 date time pickers fields (TempRequestDate & RequestDate )  and 1 drop down list that contains timeZone information (HandoffTimeZoneID)

    User select a Date and Time and also a TimeZone and then I want to convert this date & time to UTC

    here is the code that I use

     public void TempRequestDate_attr_Changed(object sender, XmlEventArgs e)
            {
                XPathNavigator xdoc = this.MainDataSource.CreateNavigator();

                if (xdoc.SelectSingleNode("/my:Job/my:Definition/@my:TempRequestDate", this.NamespaceManager).Value != "")
                {
                    //get the timeZoneInfo
                    TimeZoneInfo SelectedTimeZoneId = GetTimeZoneInfoFromID(xdoc.SelectSingleNode("/my:Job/my:Definition/@my:HandoffTimeZoneID", this.NamespaceManager).Value);

                    //get selected date
                    DateTime TempRequestDate = Iso8601ToDate(xdoc.SelectSingleNode("/my:Job/my:Definition/@my:TempRequestDate", this.NamespaceManager).Value.ToString());

                    //get Converted to UTC Date
                    DateTime RequestDate = TimeZoneInfo.ConvertTimeToUtc(TempRequestDate, SelectedTimeZoneId);

                    //set final Date
                    xdoc.SelectSingleNode("/my:Job/my:Definition/@my:RequestDate", this.NamespaceManager).SetValue(DateToIso8601(RequestDate));
                }
            }

    this code works for the first repeating section entry but how to access current value when there are several repeating section entries ?

    Thanks in advance for your help

     

     

     

     

  • 11-29-2010 02:02 AM In reply to

    Re: Get/set value of repeating section

    Instead of defiing xpathnavigator, you have to define xpathnodeiterator and specify there path till repeating group, for eg,

    XPathNodeIterator xnav = MainDataSource.CreateNavigator().Select("/my:IdeaBankFields/my:IdeaBankGrp/my:IdeaBankRepGrp", NamespaceManager);

    then you have to iterate repeating table rows using while(xnav.movenext())

    then you can set or fetch values in the repeating section using the code given below

    XPathNavigator ideaNav = xnav.Current.CreateNavigator();

    string postTitle = ideaNav.SelectSingleNode("my:IdeaTitle", NamespaceManager).Value;

      Let me know if you have some queries..

    Vishal Srivastava
    Senior Software Engineer
    SDG Software Pvt Ltd
  • 11-29-2010 02:32 AM In reply to

    Re: Get/set value of repeating section

     with your solution I still don't know what is my current row and will process all repeating section entries each time I modify on entry

    your solution works for me but I will be very interesting to know how to access only the current row

    thanks for your help

     

  • 11-29-2010 04:08 PM In reply to

    Re: Get/set value of repeating section

    If TempRequestDate is a field in your repeating group, then I'd think you'd want to use e.Site to get the current row, and relative XPaths for your node selections. Like this (if your repeating group is Definition):

     public void TempRequestDate_attr_Changed(object sender, XmlEventArgs e)
            {
                XPathNavigator xdoc = e.Site.CreateNavigator();

                if (xdoc.SelectSingleNode("../@my:TempRequestDate", this.NamespaceManager).Value != "")
                {
                    //get the timeZoneInfo
                    TimeZoneInfo SelectedTimeZoneId = GetTimeZoneInfoFromID(xdoc.SelectSingleNode("../@my:HandoffTimeZoneID", this.NamespaceManager).Value);

                    //get selected date
                    DateTime TempRequestDate = Iso8601ToDate(xdoc.Value.ToString());

                    //get Converted to UTC Date
                    DateTime RequestDate = TimeZoneInfo.ConvertTimeToUtc(TempRequestDate, SelectedTimeZoneId);

                    //set final Date
                    xdoc.SelectSingleNode("../@my:RequestDate", this.NamespaceManager).SetValue(DateToIso8601(RequestDate));
                }
            }

    Hilary Stoupa

  • 11-30-2010 01:56 AM In reply to

    Re: Get/set value of repeating section

    Thanks you so much, it's exactly what I was looking for

    Thanks all for your help

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