locked
Setting a default value for drop down list box in Infopath RRS feed

  • Question

  • Hi,

    I have a list with certain fields. I am using the data source option in Infopath to retrieve the information from the list onto a drop down box. Now I want to select a particular value in the list to be the default value in the drop down list in Infopath.

    Please let me the conditions or rules to be applied to get that functionality without code

    Thank You


    Thanks & Regards, Chandra Shekhar Rameneni
    Friday, March 11, 2011 1:31 PM

Answers

  • Is this going to be the same default value every time, or is it dependent upon other fields, or the initiator, etc.??  To set the default value of a dropdown box that has selections pulled from a secondary data source you need to view your datasource, double-click on the field that is bound to your dropdown and set the value there.  Just to reiterate - you won't be able to set the default value from the form field itself - you must do it on the actual datasource that is bound to the field.
    • Marked as answer by Peng Lei Thursday, March 17, 2011 8:38 AM
    Friday, March 11, 2011 1:37 PM
  • Hi, to set it using rules on open you go to Tools > Form Options > Open & Save > Rules (add a rule to set the field's value).  HOWEVER, if the default value method didn't work for you this will not as well.

    For the value it has to match EXACTLY to the value from the data connection.  A thing with InfoPath (XML) is that it can contain white spaces.  So, if the value from your data connection is "Value   " and you entered a default value of "Value" it will not match.  To get rid of this whitespace in your data connection you can put an RTRIM on the field (edit the query to RTRIM(field))

    • Marked as answer by Peng Lei Thursday, March 17, 2011 8:38 AM
    Monday, March 14, 2011 2:05 PM

All replies

  • Is this going to be the same default value every time, or is it dependent upon other fields, or the initiator, etc.??  To set the default value of a dropdown box that has selections pulled from a secondary data source you need to view your datasource, double-click on the field that is bound to your dropdown and set the value there.  Just to reiterate - you won't be able to set the default value from the form field itself - you must do it on the actual datasource that is bound to the field.
    • Marked as answer by Peng Lei Thursday, March 17, 2011 8:38 AM
    Friday, March 11, 2011 1:37 PM
  • Hi,

    Yes it will be the default value everytime an user opens the form and they will have to select the options from the drop down box later.

    If its not too much to ask of you could please elaborate the explanation.

    Thank You


    Thanks & Regards, Chandra Shekhar Rameneni
    Friday, March 11, 2011 1:40 PM
  • No problem... In your form click:

    • View
    • DataSource (your DataSource should open up on the right side of the screen with folders, and fields - this is where your form controls actually store the data)
    • Click on your dropdown box on your form - this will select the datasource it is bound to in that screen on the right
    • Now double-click that datasource that is highlighted on the datasource screen on the right
    • The properties will open up - it should open up to the "Data" tab
    • On that Data tab you will see a Default Value Section
    • Enter the default value you want in the box next to "Value:"
    • Click "Ok"
    • Test it out
    Friday, March 11, 2011 1:55 PM
  • Hello,

    Yes I tried the steps as you said, but its still displaying the first value from the list.


    Thanks & Regards, Chandra Shekhar Rameneni
    Saturday, March 12, 2011 5:03 AM
  • Hi All,

    I was searching for some solutions to the problem and I found this post:

    http://www.infopathdev.com/forums/p/18321/63925.aspx#63925

    Could you please take a look into this and let me know how to "set it at run time using rules".

    Thank You


    Thanks & Regards, Chandra Shekhar Rameneni
    Saturday, March 12, 2011 7:12 AM
  • Hi, to set it using rules on open you go to Tools > Form Options > Open & Save > Rules (add a rule to set the field's value).  HOWEVER, if the default value method didn't work for you this will not as well.

    For the value it has to match EXACTLY to the value from the data connection.  A thing with InfoPath (XML) is that it can contain white spaces.  So, if the value from your data connection is "Value   " and you entered a default value of "Value" it will not match.  To get rid of this whitespace in your data connection you can put an RTRIM on the field (edit the query to RTRIM(field))

    • Marked as answer by Peng Lei Thursday, March 17, 2011 8:38 AM
    Monday, March 14, 2011 2:05 PM