Copying Repeating Table in Repeating Section to next iteration of Repeating Section - InfoPath Dev
in

InfoPath Dev

Use our Google Custom Search for best site search results.

Copying Repeating Table in Repeating Section to next iteration of Repeating Section

Last post 07-01-2009 02:23 PM by harp71. 12 replies.
Page 1 of 1 (13 items)
Sort Posts: Previous Next
  • 06-29-2009 10:18 AM

    Copying Repeating Table in Repeating Section to next iteration of Repeating Section

    Hello,

    I have a Meeting Minutes Infopath Form with A repeating section (MeetingMinutes) that contains a repeating table (AttendeesList) that contains two columns (Attendees [text box] and Absent [check box].

    the repeating Section has many other fields but one of interest in this issue is a running tally of the total number of meetings held called MeetingAutoNumber (that is an autonumber field (count(preceding-sibling::*/MeetingAutoNumber) + 1))

    Once a meeting has occurred and the attendees have been listed, following meetings will always start with the preceeding meeting's attendees

     What I would like to accomplish is to copy the immediate preceeding section's AttendeesList's Attendees into the current Section's AttendeesList as a starting point for the next meeting.

    This is a browser enabled form

    I am not averse to adding a button to the form to kick this off... but would prefer to automate this process on creation of the next section...

    Any ideas on this would be greatly appreciated.

     

  • 06-29-2009 10:55 AM In reply to

    Re: Copying Repeating Table in Repeating Section to next iteration of Repeating Section

    Have you tried the CopyTable qRule from Qdabra (here on this site)?  It might accomplish what you need for copying data from one repeating table to the next.  For a browser form, it might require administrative approval, though.

  • 06-29-2009 01:23 PM In reply to

    Re: Copying Repeating Table in Repeating Section to next iteration of Repeating Section

    Qdabra states that these do not work in Browser enabled forms...

     

  • 06-29-2009 01:28 PM In reply to

    Re: Copying Repeating Table in Repeating Section to next iteration of Repeating Section

    That's why I wrote my last sentence.  It's not that they don't work in browser forms.  It's that qRules inject code into the form, and browser-enabled forms with code require administrative approval and deployment.  If that's ok, then it's an option.  Otherwise....

  • 06-29-2009 02:28 PM In reply to

    Re: Copying Repeating Table in Repeating Section to next iteration of Repeating Section

    I see said the blind man...

     I've been trying to play with this one for a while... to no avail... I feel like I am missing something here...

     

    My data source structure:

    myFields > (repeating section) MeetingMinutes > (repeating Table) AttendeesList

    at run time; after adding an additional repeating section to the form I want my users to be able to click on the button and have the prior instance of the repeating section's repeating AttendeesList table be copied over to the newly created one:

    How do you specify the prior instance of the repeating section correctly...

    this currently errors out when I try it...

    CopyTable /tablesrc=preceding-sibling::/my:myFields/my:MeetingMinutes[1]
    /rowsrc=my:AttendeesList
    /tabledest=/my:myFields/my:MeetingMinutes
    /rowdest=my:AttendeesList
    /empty=yes

     

    I have also attempted to use this one instead:

    Replace /xpathsrc=preceding-sibling::/my:myFields/my:MeetingMinutes[1]/my:AttendeesList
    /xpathdest=/my:myFields/my:MeetingMinutes/my:AttendeesList

    both error out (I am assuming because of the preceding-sibling issue...

    I think I am up against a syntax issue here... any thoughts?

  • 06-29-2009 03:26 PM In reply to

    Re: Copying Repeating Table in Repeating Section to next iteration of Repeating Section

    This is a new scenario that I haven't thought through yet, but I do know that getting the syntax correct can be tough, since there is no validation engine.  Hopefully, Hilary will be able to see this and help you through it, because she is very good with this.  I have only just started playing with qRules in the last week, so I've only taken a simple repeating table and copied it to another repeating table, but these were two separate entities on my main data source, not the same entity repeated in a new section.

  • 06-29-2009 03:49 PM In reply to

    Re: Copying Repeating Table in Repeating Section to next iteration of Repeating Section

    Can you attach your template in a reply so that I can see your data structure and what you are currently trying? Under the Options tab in your reply, you have the option of adding a template...

    Hilary Stoupa

  • 06-30-2009 06:37 AM In reply to

    Re: Copying Repeating Table in Repeating Section to next iteration of Repeating Section

    Hilary,

    Here is the template... I have two parallel dev. efforts on this right now...

    1) attached xsn using qRules

    2) VSTO basically same template with an event handler off of the button see below: (I know that this does not work correctly... this is just the current iteration of where I am at in trying to correctly id the prior iteration vs the current one...

    public void CopyAttendees_Clicked(object sender, ClickedEventArgs e){    XPathNavigator myNavigator =   this.MainDataSource.CreateNavigator();
    //XPathNavigator nameNode = myNavigator.SelectSingleNode("my:myFields/my:MeetingMinutes", NamespaceManager);
        XPathNodeIterator nodes = myNavigator.Select("/my:myFields/my:MeetingMinutes", NamespaceManager);
        for (int i = 1; i < nodes.Count; i++)
        {
            nodes.MoveNext();
        }   
        nodes.Current.MoveToAttribute("my:AttendeesList","");    
        XPathNavigator OldNavigator = nodes.Current;
       
    XPathNodeIterator OldNodes = OldNavigator.Select("/my:myFields/my:MeetingMinutes/my:AttendeesList", NamespaceManager);
        for (int i = 1; i < OldNodes.Count; i++)
        {
            OldNodes.MoveNext(); 
        }

    I believe that I have a syntax issue in trying to correctly select the previous iterations repeating table correctly in order to copy it...

    Ideally all I need to copy is just the first column (Attendees) from the prior iterations (MeetingMinutes) repeating table (AttendeesList).

    Notes: This is a browser enabled form... and I do have the ability to administratively deploy this... so code is not a problem.

    Any help would be greatly appreciated.

     

  • 06-30-2009 07:48 AM In reply to

    Re: Copying Repeating Table in Repeating Section to next iteration of Repeating Section

    Hi -- I modified the XPath syntax in your qRules command on the button on your form. Since your button is not located inside the repeating section, preceding-sibling is meaningless. Instead, I selected the 'next to last' meeting using an XPath filter of [last() -1] and the last meeting using [last()]. This always copies the info from the next to the last attendees list to the final attendees list. I also switched to using the Copy Table command. Give it a try and let me know if you have any questions, okay?

    Hilary Stoupa

  • 06-30-2009 11:37 AM In reply to

    Re: Copying Repeating Table in Repeating Section to next iteration of Repeating Section

    Thanks Hillary!

    That worked like a charm...

    One last question... If I am then trying to clear out the absent column for this recently copied field... is this possible?

    I have attached a form with my attempt at this...
    basically I added a CurrentMeetingNumber field that is a copy of the most recent MeetingAutoNumber
    I then added anther rule to compare the two for a match and if the Absent field is set to "yes" I want to set it to "no" only for that new copy...
    however, when I attempt this it wipes out all Absent check boxes everywhere on the form... I know why this is occurring but not how to get the results I am looking for...

    Any thoughts?

     

  • 06-30-2009 12:56 PM In reply to

    Re: Copying Repeating Table in Repeating Section to next iteration of Repeating Section

    Hillary...

    I think I figured a somewhat circuitous way round this problem... see attachment...

    Not sure if it is the most eloquent solution... but it works...

    Thanks

     

  • 07-01-2009 08:04 AM In reply to

    Re: Copying Repeating Table in Repeating Section to next iteration of Repeating Section

    I think it is a good solution. However, with a little bit of trickery, we can apply a filter to a rule's target field. I've attached a sample, and check out this blog post on how it was done.

    Hilary Stoupa

  • 07-01-2009 02:23 PM In reply to

    Re: Copying Repeating Table in Repeating Section to next iteration of Repeating Section

    This solution is the elegant one that I was looking for... thanks again!

     

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