To add a dropdown to a FIM Portal RCDC you can use the UocDropDownList control. This post shows you three (and a half) different ways to populate the choices.
1. Hard-coded in the control
Hard-coding is best for when you have a small number of possibilities that are unlikely to change, such as in this example from the standard Group Edit RCDC:
<my:Control my:Name="Scope" my:TypeName="UocDropDownList" my:Caption="{Binding Source=schema, Path=Scope.DisplayName}" my:RightsLevel="{Binding Source=rights, Path=Scope}"> <my:Options> <my:Option my:Value="DomainLocal" my:Caption="%SYMBOL_DomainLocalCaption_END%" my:Hint="%SYMBOL_DomainLocalHint_END%"/> <my:Option my:Value="Global" my:Caption="%SYMBOL_GlobalCaption_END%" my:Hint="%SYMBOL_GlobalHint_END%"/> <my:Option my:Value="Universal" my:Caption="%SYMBOL_UniversalCaption_END%" my:Hint="%SYMBOL_UniversalHint_END%"/> </my:Options> <my:Properties> <my:Property my:Name="Required" my:Value="true"/> <my:Property my:Name="ValuePath" my:Value="Value"/> <my:Property my:Name="CaptionPath" my:Value="Caption"/> <my:Property my:Name="HintPath" my:Value="Hint"/> <my:Property my:Name="ItemSource" my:Value="Custom"/> <my:Property my:Name="SelectedValue" my:Value="{Binding Source=object, Path=Scope, Mode=TwoWay}"/> </my:Properties> </my:Control>
2. Look up in the Schema
One nice way to handle the list is to enter the values into the Verification regex of the attribute’s binding object. You can then instruct the RCDC to look the values up in the schema, and if you want to change them later there is no need to edit the RCDC. The down side to this approach is that you run up against the character limit in the validation string very quickly – so this only works for a short list of options.
By default the same validation regex is defined for both the EmployeeType attribute and binding, however this UocDropDownList control only seems to use the Binding one. This isn’t the default, but here’s an example of what you might have in the validation string:
^(Employee|External|Service|Admin)?$
Then in the RCDC you tell it that the “ItemSource” comes from the schema:
<my:Control my:Name="EmployeeType" my:TypeName="UocDropDownList" my:Caption="{Binding Source=schema, Path=EmployeeType.DisplayName}" my:Description="{Binding Source=schema, Path=EmployeeType.Description}" my:RightsLevel="{Binding Source=rights, Path=EmployeeType}"> <my:Properties> <my:Property my:Name="Required" my:Value="{Binding Source=schema, Path=EmployeeType.Required}" /> <my:Property my:Name="ValuePath" my:Value="Value" /> <my:Property my:Name="CaptionPath" my:Value="Caption" /> <my:Property my:Name="HintPath" my:Value="Hint" /> <my:Property my:Name="ItemSource" my:Value="{Binding Source=schema, Path=EmployeeType.LocalizedAllowedValues}" /> <my:Property my:Name="SelectedValue" my:Value="{Binding Source=object, Path=EmployeeType, Mode=TwoWay}" /> </my:Properties> </my:Control>
3. XmlDataSource
I regularly find I have too many choices to use the schema method. Unfortunately there is, as yet, no way to actively update the list of choices from, say, a database table – so I have to hard-code the options into an XmlDataSource section in my RCDC.
You can define multiple XmlDataSource sections at the top of the RCDC, before the my:Panel section. Here’s an example listing site names:
<my:XmlDataSource my:Name="Sites"> <Sites> <SiteCode Code="" Name="" /> <SiteCode Code="001" Name="Rue du Rhone, Geneva" /> <SiteCode Code="002" Name="Place de la Concorde, Paris" /> <SiteCode Code="003" Name="Alexanderplatz, Berlin" /> <SiteCode Code="004" Name="Pitt St, Sydney" /> </Sites> </my:XmlDataSource>
I now refer to this list of options in the “ItemSource” part of my UocDropDownList control. The neat trick I’m doing here is to show the user the friendly names of the sites, but then to write the code into the object’s SiteCode attribute by specifying @Code in the “ValuePath” option.
<my:Control my:Name="SiteCode" my:TypeName="UocDropDownList" my:Caption="Site" my:Description="{Binding Source=schema, Path=SiteCode.Description}" my:RightsLevel="{Binding Source=rights, Path=SiteCode}"> <my:Properties> <my:Property my:Name="Required" my:Value="{Binding Source=schema, Path=SiteCode.Required}"/> <my:Property my:Name="ValuePath" my:Value="@Code"/> <my:Property my:Name="CaptionPath" my:Value="@Name"/> <my:Property my:Name="HintPath" my:Value="@Code"/> <my:Property my:Name="ItemSource" my:Value="{Binding Source=Sites, Path=/Sites/*}"/> <my:Property my:Name="SelectedValue" my:Value="{Binding Source=object, Path=SiteCode, Mode=TwoWay}"/> </my:Properties> </my:Control>
3.5 XmlDataSource with String Resources
A variation on the XmlDataSource method can be seen by looking at how the Regions are specified in the default User RCDCs. You’ll see lots of tags like “%SYMBOL_FOCaption_END%” – where do these come from?
If you look on the Localization tab for the RCDC configuration you’ll see a whole bunch of XML in the String Resources field, and this is where the tags are defined. The idea here is that you can use a generic tag in the RCDC and then replace it with the localized version, however you could also use this functionality to make the option text a little easier to change.
 4. Drop-down selection of reference objects
See <a href=”http://theidentityguy.blogspot.com.au/2011/07/populating-rcdc-dropdownlist-with.html”>http://theidentityguy.blogspot.com.au/2011/07/populating-rcdc-dropdownlist-with.html</a>
Great post as usual Carol! Just a word of advice. I had big trouble copying the XML from your website. Hidden characters or something was causing the RCDC to fail. Ended up copying the EmployeeType and Country XML blocks directly from the exported RCDC. Made the required edits and works great!
Cheers!
Oh, and I found that you can only have 130 characters in the Schema Validation string so that could also drive which method to use.
Hi Carol,
Quick question. In your 3rd example,
Is it possible to modify it as below:
And be able to use both the code and the newly defined ‘Zip’ value as an attribute?
Thanks,
Tim
Looks like something has been stripped from your comment