Tuesday 15 February 2011

Lookups in InfoPath when you don't want the dropdown value

Sometimes you want to get a value based on a dropdown, but not actually the value in the ID column. For example, I have a list of project roles as below













RoleIdNameValue
1Consultant15
2Senior Consultant20


Here I want a dropdown listing "Consultant" and "Senior Consultant". I need the. I then want to retrieve the corresponding value for use in a calculation. If you try this straight off, you will find that you always get the value first item from the list. This is because the context of which node you want is confused. To provide the "correct" context, you probably want an XPath query like below



../../../my:Roles/my:Role/my:RoleSaleValue[../my:RoleID = current()/../my:TaskRole]


More information can be found in this rather nice article. http://blogs.msdn.com/b/infopath/archive/2004/09/13/228881.aspx