Tuesday, July 26, 2011

Populating a RCDC dropdownlist with object masterdata information in FIM 2010 Portal

I have been playing around with the idea of populating master data (i.e. Department, Location,etc) into the FIM Portal and having this data presented in a dropdownlist. Presenting this information in a identitypicker, hyperlink, or listview is documented will enough so I will focus solely on the dropdownlist in this post.

Firstly I built a class called Department, added the relevant Attributes and binded everything up nicely. Next, I imported the departments into the Portal and tried to populate the dropdownlist. Here i ran into my first snag, as I could not populate this using the normal datasources provided in the RCDC datasources as per the Microsoft RCDC reference guide http://technet.microsoft.com/en-us/library/ee534918(WS.10).aspx#BKMK_DataSources.

I had a look at some of the posts on the FIM Forums, and saw an undocumented data source mentioned in the  http://social.technet.microsoft.com/Forums/en-HK/ilm2/thread/ae6e6eb4-e84b-44a7-8fd2-a9538cee4670 forum. I did some investigation and found that this data source was able to search objects and could easily populate my dropdownlist by creating a data source  in my RCDC configuration as below:

<my:ObjectDataSource my:TypeName="PrimaryResourceObjectDataSource" my:Name="object" my:Parameters=""/> 
<my:ObjectDataSource my:TypeName="PrimaryResourceDeltaDataSource" my:Name="delta"/>

<my:ObjectDataSource my:TypeName="PrimaryResourceRightsDataSource" my:Name="rights"/>
<my:ObjectDataSource my:TypeName="SchemaDataSource" my:Name="schema"/>

<my:ObjectDataSource my:TypeName="DomainDataSource" my:Name="domain"/>
<my:ObjectDataSource my:TypeName="TimeZoneDataSource" my:Name="timezone"/>

<my:ObjectDataSource my:TypeName="UocSearchDataSource" my:Name="search"/>

Now i was able to my create my dropdownlist object bound to department as below:

<my:Control my:Name="department" my:TypeName="UocDropDownList" my:Caption="{Binding Source=schema, Path=department.DisplayName}" my:Description="{Binding Source=schema, Path=department.Description}"  my:RightsLevel="{Binding Source=rights, Path=department}">
<my:Properties>
<my:Property my:Name="Required" my:Value="{Binding Source=schema, Path=department.Required}"/>
<my:Property my:Name="Columns" my:Value="40"/>

<my:Property my:Name="ItemSource" my:Value="{Binding Source=search, Path=Department}"/>
<my:Property my:Name="SelectedValue" my:Value="{Binding Source=object, Path=department, Mode=TwoWay}"/>
</my:Properties>
</my:Control>

There was however only one problem which I still had to resolve; being that although the values in the dropdownlist items were displayed as text, selecting an item stored the reference value of the selected item in the department attribute value.I looked at various options, and finally found the solution.

Enter the reference binding! Thanks to Almero (PuttyQ) for pointing me to a post by UNIFYBob http://social.technet.microsoft.com/wiki/contents/articles/3945.aspx which gave me the final pieces to the puzzle. By creating a reference (departmentRef in this case) and binding this value to the person, I was able to pass the reference correctly. So I amended my RCDC control to look a follows:

<my:Control my:Name="departmentRef" my:TypeName="UocDropDownList" my:Caption="{Binding Source=schema, Path=departmentRef.DisplayName}" my:Description="{Binding Source=schema, Path=departmentRef.Description}" my:RightsLevel="{Binding Source=rights, Path=departmentRef}">
<my:Properties>
<my:Property my:Name="Required" my:Value="{Binding Source=schema, Path=departmentRef.Required}"/>
<my:Property my:Name="Columns" my:Value="40"/>

<my:Property my:Name="ItemSource" my:Value="{Binding Source=search, Path=Department}"/>
<my:Property my:Name="SelectedValue" my:Value="{Binding Source=object, Path=departmentRef, Mode=TwoWay}"/>
</my:Properties>
</my:Control>

Now I was able to build some Portal or SyncEngine rules to push this information to my connected data sources.