How to get the Display Name of a DropDown Lis tBox?
-
Thursday, May 03, 2012 8:54 AM
Dear all,
I have a drop down list box with the pair value - display name.
When the user select an entry from the drop down the value is copied into a textbox (i'm using the Action "set a field value" for doing this)
...but I need also the Display Name to copied into another textbox...how can I do this?
THANK YOU!!!
All Replies
-
Thursday, May 03, 2012 12:23 PM
The list box choices for the dropdown list has to come from somewhere else, it can't be the choice: "enter manually".
So, either from somewhere else in the form (you can create a hidden repeating area that's not shown on the form, and enter different default value rows to populate it), or from a secondary data source (list, or even just an external XML file).
Assuming now you have a secondary data source from this XML.
<names>
<name><display>John Liu</display><value>jliu</value></name>
<name><display>John Doe</display><value>jdoe</value></name>
</names>Your first rule for setting the value is fine. The rule would be something like:
set /my:myFields/my:value1 to /my:myFields/my:dropdown1
To get the display value, you need to grab it from the list, but filter it using the currently selected value.
set /my:myFields/my:display1 to xdXDocument:GetDOM("Names")/names/name/display[../value = current()]
you can also use:
set /my:myFields/my:display1 to xdXDocument:GetDOM("Names")/names/name/display[../value = xdXDocument:get-DOM()/my:myFields/my:dropdown1]
current() will only work if the rule is run on the dropdown itself. Current refers to the immediate bound field.
if you are using lists or some other schema for your dropdown list, you'll need to change your XPath accordingly.
http://johnliu.net/storage/DropdownDisplayValueForm.xsn
jliu - http://johnliu.net - http://sharepointgurus.net
- Proposed As Answer by Zach Little Thursday, May 03, 2012 7:39 PM
- Marked As Answer by Emir LiuMicrosoft Contingent Staff, Moderator Monday, May 07, 2012 7:59 AM
-
Thursday, May 03, 2012 6:38 PM
WOW!!
Thank you very much!!!!!

