Repeating Section, The current() Function, and a Button - InfoPath Dev
in

InfoPath Dev

Repeating Section, The current() Function, and a Button

Last post 12-09-2008 11:51 AM by Hilary Stoupa. 11 replies.
Page 1 of 1 (12 items)
Sort Posts: Previous Next
  • 12-04-2008 03:41 PM

    Repeating Section, The current() Function, and a Button

    Hello Everyone.  Its me again.

    I have a repeating section with a date field that I need to populate with today's date when a button is clicked.  The repeating section first appears in view "b" where everything is filled out with the exception of a few fields including the date field in question.  I switch to view "c".  The information displayed in view "c" is controlled by a dropdown in view "b" labeled 'Include in view "c"' (clever, I know).  The form may contain many iterations of the repeating section, but I need to only populate the date field in the sections that have the 'include in view c' dropdown set to yes (and thereby displayed in view c).

    I can get it to populate every instance of the date filed, but not just the ones that I want.  I am sure that I am close, but I am just getting the syntax wrong or something.  Should I use a rule on the button to set the date and put a condition on it using the 'expression' option?  That is the most explored method and I have come up empty.

    Any suggestions would be greatly appreciated.

    Fishman
  • 12-04-2008 04:11 PM In reply to

    Re: Repeating Section, The current() Function, and a Button

    Hi there!

    Now, I may be about to grossly oversimplify the issue, so forgive me if I do....

    Can't you just add a rule to the field bound to the dropdown in the 'Include in view c' (and I can't talk about cleverness, I name everything 'test'...) that then sets the date field for that row if the value is 'yes'?

    Are you using InfoPath 2003? I forget....

    Hilary Stoupa

  • 12-04-2008 04:19 PM In reply to

    Re: Repeating Section, The current() Function, and a Button

    Here is a quick sample... Righ click the link, save as, open in design mode.... Type yes in the first field of the table and the third field gets today().

    Hilary Stoupa

  • 12-04-2008 04:21 PM In reply to

    Re: Repeating Section, The current() Function, and a Button

    Hello Hilary!  So good to hear from you again!  IP 2007 aaaaannnnnnnddddddddd C#.  That would solve the problem, but I would like for the button to do the job.  The button (in view 'c') actually creates an email with that veiw embedded in the form and the date that the email was sent is what I am trying to grab.  Theoretically, one could switch the drop down and not send the email.  You know how that goes.  I would not make a big deal out of it, but that date ends up on a report and, well, we all know how management is about their reports!

    Fishman
  • 12-04-2008 04:34 PM In reply to

    Re: Repeating Section, The current() Function, and a Button

    I see, I see. Well, I can't think of a way to do this with a rule. You know, the Action to 'Set a field's value' -- what we really want is be able to put an XPath in there to select only the nodes where the Include in view field is equal to 'yes'....and we can't, now can we! That's why all of your fields get set with the date. You may have to add some code for this -- XPath to select a node list of all the nodes where the include in view field equals 'yes' and then loop through and set that date field.....

    Hilary Stoupa

  • 12-04-2008 04:44 PM In reply to

    Re: Repeating Section, The current() Function, and a Button

    I was fooling around with that a bit but I wasn't able to get it to work.  Is it possible to use the 'expression' option when setting the condition for the rule?  I was making afeeble attempt at that earlier but no dice.  Here is one of my concoctions:

    dfs:dataFields/d:Buyers/d:WorkOrders/d:WorkOrderConcern/@IncludeInWorkorder[../@ConcernID = current()/WorkOrderConcern]

    Workorders is a repeating group containing workorderconcern containing the ddl includeinworkorder.  ConcernID is a unique number generated by the db when the form submitted.  Each repeatiing section gets one so I was trying to grab that to identify the row to set the field in.  The condition also required that includeinworkorder = 'yes'.  Am I on the right track here?

    Fishman
  • 12-04-2008 06:14 PM In reply to

    Re: Repeating Section, The current() Function, and a Button

    Wow, I'm not sure on that.

    However, if you can add another field to your data source, we can do this with rules.... in the attached sample, add some rows to the table, type 'yes' in some of them in field one, and click the button, field three gets the date....The rule on the button sets the value of another field that isn't displayed on the form but is part of the repeating group, and that field then populates the dates....Your form is data base bound, it looks like from your XPath, so you should be able to add a field to the WorkOrderConcern group...

    Hilary Stoupa

  • 12-05-2008 08:01 AM In reply to

    Re: Repeating Section, The current() Function, and a Button

    WOW!  Was I ever trying to do that the hard way!  I tried to use triggers and couldnt work out the logic, but with your example, I finally got it!  Thanks again Hilary!

    Fishman
  • 12-05-2008 08:46 AM In reply to

    Re: Repeating Section, The current() Function, and a Button

    Just for GP......

    I had to add a rule to the trigger field to set itself back to false or the operation only worked the first time.  All is just swell now!

    Fishman
  • 12-05-2008 09:30 AM In reply to

    Re: Repeating Section, The current() Function, and a Button

    Fantastic! Love it when a plan comes together....

    Hilary Stoupa

  • 12-06-2008 11:57 AM In reply to

    Re: Repeating Section, The current() Function, and a Button

    Cool trick Hilary!

    I wanted to take my own stab at this problem, and I think there is a sneaky way to do just what you(BuildPro Guru) describe without using triggers, though it involves cracking open the .XSN.  Please see another post of mine:

    http://www.infopathdev.com/forums/p/9316/33499.aspx#33499

    and the contents of the attached XSN.  Unlike in my other post, in this case you would only need one rule and in the brackets[] instead of an index number you would have a condition.  I believe in this case it would be something like:

    dfs:dataFields/d:Buyers/d:WorkOrders/d:WorkOrderConcern/@date[../@IncludeInWorkorder = 'yes']

    But I'm only guessing about where exactly the date node is located and what it's called.
    Anyway, feel free to give it a try.

    Jimmy Rishe / Software Developer / Microsoft MVP
    Qdabra Software
  • 12-09-2008 11:51 AM In reply to

    Re: Repeating Section, The current() Function, and a Button

    Oh, I like that. Very nice, especially if you have a data source you can't modify for some reason.

    Hilary Stoupa

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