How to get the value of a text field that is unknown at design time - InfoPath Dev
in

InfoPath Dev

How to get the value of a text field that is unknown at design time

Last post 06-19-2012 06:07 AM by sheilaA. 3 replies.
Page 1 of 1 (4 items)
Sort Posts: Previous Next
  • 06-18-2012 11:31 AM

    How to get the value of a text field that is unknown at design time

    I am trying to write a rule that sets the value of a field with another field's value that is not known at design time.

     Depending on which option is selected (1,2,...) I want to select the value from fields: comm_1, comm_2, comm_3,....., comm_n and put it into Field A

    So I have 3 fields involved in this rule.

    #1 The option group field that the user will select <-- Known (this is the field the rule is set on)

    #2 The field that will get the value <-- Known

    #3 The field that has the value I need to set #2 above <-- Unknown at design time

    I tried this and it does not work:

        concat("../my:comm_1text/my:comm_", .)

    When I select option 2, I get this value in Field A:

         ../my:comm_1text/my:comm_2 <=== this is the name of the field that has the value.

    Any suggestions?

  • 06-19-2012 12:12 AM In reply to

    Re: How to get the value of a text field that is unknown at design time

    Created a new Infopath 2010 form.  


    Inserted option button (with default "Number of options buttons to insert;" 3) , named it "Options"

    In addition to textbox FieldA, inserted 3 textboxes, named them:
    • comm_1
    • comm_2
    • comm_3
    This is to repeat for each option:
    With focus on Options, on ribbon "Add rule" (later "Manage rules")
    In "Rules" pane, New --> Action
    Condition: Options = 1 (in last drop-down-lis choose "Type a number..." )
    Rule type: Action
    Run these actions" --> Add --> in opened "Rule Details" dialog:
      • Action: --> Set a field's value
      • Field  --> FieldA
      • Pressed fx against "Value:"  textbox  --> "Insert Field or Group..." -->  comm_1 

    Add new rule for "Options" by "This is to repeat for each option: " procedure with corresponding minor adjustments of digit :
    With focus on Options, on ribbon "Add rule" (later "Manage rules")
    In "Rules" pane, New --> Action
    Condition: Options = 2 (in last drop-down-lis choose "Type a number..." )
    Rule type: Action
    Run these actions" --> Add --> in opened "Rule Details" dialog:
    • Action: --> Set a field's value
    • Field  --> FieldA
    • Pressed fx against "Value:"  textbox  --> "Insert Field or Group..." -->  comm_2 
    Add a new rule by the same procedure "This is to repeat for each option: " with digit, 3, then 4, then n....

    Publish, Run and enjoy
    Gennady Vanin (Novosibirsk) --- Геннадий Ванин (Новосибирск)
  • 06-19-2012 05:15 AM In reply to

    Re: How to get the value of a text field that is unknown at design time

    It should be possible to pull this off with a single rule action and no conditions.  As you've discovered, concat("../my:comm_1text/my:comm_", .) won't work because that just produces the text value ../my:comm_1text/my:comm_X.

    How about something like this:

    ../my:comm1_text/*[local-name() = concat('comm_', current())]

    Jimmy Rishe / Software Developer / Microsoft MVP
    Qdabra Software
  • 06-19-2012 06:07 AM In reply to

    Re: How to get the value of a text field that is unknown at design time

    Jimmy:

    It should be possible to pull this off with a single rule action and no conditions.  As you've discovered, concat("../my:comm_1text/my:comm_", .) won't work because that just produces the text value ../my:comm_1text/my:comm_X.

    How about something like this:

    ../my:comm1_text/*[local-name() = concat('comm_', current())]

    Using a single rule is exactly what I am looking for.  This looks promising, I'll give it a try.

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