Geeks With Blogs

Steve Clements .Net and then some....

The more I work and develop with SharePoint I am learning that 95% of the task, with a little guidance is a walk in the park, especially when compared to that final 5%, which is either impossible or is the most painfully experience any developer can experience!!

Take my Friday hell for an example...

A requirement comes in for custom news item, with a property that is the users department, but could be changed to another. Sure i think, drop down control, bind to all the possible departments, auto select the user department, getting the value from the users profile.

Converting that into SharePoint, create a custom field, inherit from SPFieldChoice, bind to an SPList with all the groups (add to the base.Choices collection), get the current user from the SPContext, use that to the query the users profile to get the department, set the base.DefaultValue. Cool, now that is sweet, test in a simple column adding to a list, works a treat. The field is wanted for a page content type though so...

Create a site column, add to content type, create custom page layout, drop on...we are rocking so far.

Go to create a page and my group is selected, awesome. Change my group just to test, but nope still selects old group...hmmm...iisreset....nope the same. Test with other users, the same!! Just to confirm, its not selecting the first item in the list, its selecting the department of the admin user who deployed the solution, and what it was when they deployed it!!!!! Now that is nuts, go into a standard list, works a treat!! After hours of thrashing, trying to add it directly as a column to the page library and many others i gave up and came up with a far less appealing solution but a solution none the what the feck is going on here???

Its worth noting that i put some trace code in and found that the correct department was being pulled through, and checking what base.DefaultValue was after setting it showed it was what I expected, but on the page was the admin's original group. If anyone else has experienced similar it would be great to here from you, I can post some code if you like, but its pretty simple stuff and like i said, works in standard items.

I did actually take the time this weekend to create a custom field rendering my own drop down list, the value is auto selected as I would expect, but I the value doesn't display in the "View Properties" or "Published Page" mode, fine in "List View"....its metal!

P.S. I have another one to with sub classing the CQWP, that I might post later.


Posted on Monday, June 30, 2008 7:17 AM .NET 3.5 , Sharepoint | Back to top

Comments on this post: MOSS | Custom Field, drop down auto select hell

# re: MOSS | Custom Field, drop down auto select hell
Requesting Gravatar...
Go to create a page and my group is selected, awesome.
Left by fasthoup on Feb 13, 2009 5:27 PM

Your comment:
 (will show your gravatar)

Copyright © Steve Clements | Powered by: