Best Time/Place to Run Code? - InfoPath Dev
in

InfoPath Dev

Best Time/Place to Run Code?

Last post 03-14-2012 11:03 AM by Jimmy. 7 replies.
Page 1 of 1 (8 items)
Sort Posts: Previous Next
  • 03-13-2012 07:00 PM

    Best Time/Place to Run Code?

    Hi InfoPathers:

    Pardon me if this a basic question because I don't know IP coding very well.   When my IP 2010 filler form opens, I want to automatically set some text in 2 columns of a repeating table that has 13 rows that show by default.  I've locked the user down from adding or removing any rows to this column since it's just a summary table.  Since different text needs to be set for the two columns I'm interested in, I don't think I can use the Default Value for the text fields in question, so I have written code that should set the text I want based on row number.  I'm thinking that the form loading event is not the right place to run this code because the views haven't yet initialized (at least, not if I've understood the loading event properly).  I don't think I want to run it when I switch to the View in question because I only want to run it when my repeating table is blank and not every time I move to that view. 

    Do any of you know if there is an easy way set all my fields in one fell swoop and to only have to set them once?

    Thanks,

    nkstrou

    An imprecisely defined requirement has an infinite number of possible solutions. Unfortunately, only about a maxiumum of 3 solutions are actually satisfactory to the end user.
    Filed under: , , , ,
  • 03-13-2012 10:08 PM In reply to

    Re: Best Time/Place to Run Code?

    The default values dialog should allow you to set different values in each row.  Have you given that a try?  We always suggest avoiding using unnecessary code.
    Jimmy Rishe / Software Developer / Microsoft MVP
    Qdabra Software
  • 03-14-2012 07:16 AM In reply to

    Re: Best Time/Place to Run Code?

    Jimmy:

    I would prefer to avoid unnecessary code as well.  How do you use Default Value to specify different data per row in a repeating table?  It's not intuitive to me how you would do that.  I know you can use position() to get the row number, but I've not seen a way to set up something like If-Then-Else logic for Default Value. 

    Thanks,

    nkstrou

    An imprecisely defined requirement has an infinite number of possible solutions. Unfortunately, only about a maxiumum of 3 solutions are actually satisfactory to the end user.
  • 03-14-2012 08:26 AM In reply to

    Re: Best Time/Place to Run Code?

    In the same location you added your repeating group 13 times, you can drill down into each repeating group and set different defaults for the fields. So, if you had 13 instances of a group called Group1, and it has a field called Field1 inside it, each instance of Field1 could have a different value.

    Hilary Stoupa

  • 03-14-2012 09:42 AM In reply to

    Re: Best Time/Place to Run Code?

    Well duh, why didn't I think of that?  Thanks Hilary - you rock!!!

    Another question while I have you.  Given that I've set up the 13 rows in my table, if I want to set an action rule from elsewhere in my document to update a given textbox on one of the rows, is there a way I can use position() (or any other condition) to identify the row(s) I want?   I know you can't apply a filter to the field you want to update, or at least there's not a button to go add a filter like there is other areas.  Do you have any suggestions?

    Thanks,

    nkstrou

    An imprecisely defined requirement has an infinite number of possible solutions. Unfortunately, only about a maxiumum of 3 solutions are actually satisfactory to the end user.
  • 03-14-2012 09:52 AM In reply to

    Re: Best Time/Place to Run Code?

    If you aren't afraid to work with your form's source files, you can modify the manifest to do this - see this blog post.

    qRules also has a command for this (among tons of other commands that can prevent having to add custom code to your form).

    Hilary Stoupa

  • 03-14-2012 10:20 AM In reply to

    Re: Best Time/Place to Run Code?

    Question about QRules:  if I build a form using it, do people who open the form who don't have QRules installed have problems using the QRules functionality?  Do they need the software, too, or at least an add-in of some kind? 

    Thanks,

    nkstrou

    An imprecisely defined requirement has an infinite number of possible solutions. Unfortunately, only about a maxiumum of 3 solutions are actually satisfactory to the end user.
  • 03-14-2012 11:03 AM In reply to

    Re: Best Time/Place to Run Code?

    When a form uses qRules, the qRules functionality is all built into the form template (XSN) so users do not have to have anything special installed on their systems (aside from InfoPath of course) in order to use the forms.
    Jimmy Rishe / Software Developer / Microsoft MVP
    Qdabra Software
Page 1 of 1 (8 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.