in

SharePoint Blogs

The Best Place for SharePoint-related Blogs

Aaron Robertson-Hodders SharePoint Blog

Return to Custom Field properties

A while ago I posted about Custom Field Type, wherein I mentioned a problem I was having getting my custom properties to stick when saving a field.

I posted a question to the MSDN Forum about this and received a pretty promising response, which goes half way but is still not the complete answer.

The response from Anton Myslevich (thanks Anton!) has details of defining the properties in the propertyschema element, making them hidden, overriding the Update method to set the custom properties like this...

        public override void Update()
        {

            this.SetCustomProperty("MyProp", this.MyProp);
            base.Update();

        }

...and then using an Init method that is called from the constructors to set the values when the custom field is edited...

        private void Init()
        {
            this.MyProp = this.GetCustomProperty("MyProp") + "";
        }

This works great for the edit/save/re-edit process, but it still does not save the properties when a new instance of the field is created. For my current purposes, this is ok, because I cam deploying the custom field type as part of a list definition and so my instance is created already and because editing now works ok, I'm saved - for now.

I'm still pretty keen to know how to get the entire process working properly, and I'm wondering if I can perhaps modify the field definition to show the propertyschema fields initially, and then hide them and show the custom field editor control when the field is edited.

If anyone has any further thought, I'd be more than happy to hear them...

Comments

 

Thomas Carpe said:

I'm having similar issues with properties in a custom field even if they only leverage the OOTB types like Text and MultiChoice.

What happens is that I can enter them and save them, and if I step through the debugger I can see that the data was definitely saved to them (this.Field.GetCustomProperty[myPropertyName] works), but when I go back to the FldEditEx.aspx page to modify them, the data isn't there, and it is usally replaced by either a weird arrangement of checkboxes or text like "<My Field Title> field value."

Note that i am using custom fields and field controls but that my property schemas are done entirely in the FIELDSTYPES.xml file. :-)

This behavior is very odd, and I thought it might be realted to this old hotfix support.microsoft.com/.../932055 which perhaps didn't make it into the security rollups from Sept and Oct.? I am thinking of opening a support issue. I really don't want the hassle of having to create some custom controls for what should just work as is.

I'll let you know if I find a workaround for this, as maybe it will also help with the custom property controls as well.

October 18, 2007 11:47 AM
 

DocWattsMan said:

I got a workaround - for now. You can get by without writing custom field editor controls if you use this code. :-) Thanks for the background info, it really helped me get to the bottom of this isssue.

November 1, 2007 1:34 PM
 

Alex Rybin said:

Guys, just install hotfix and take it easy.

I just did it and everything works....

January 9, 2008 6:08 PM
 

Access Custom Field Type Child Elements Customization « PANVEGAs Blog said:

Pingback from  Access Custom Field Type Child Elements Customization &laquo; PANVEGAs Blog

October 2, 2008 2:25 PM

Leave a Comment

(required )  
(optional )
(required )  
Add

About adrh

I'm a Kiwi, living in Australia (for the past 10 years). I work for MacroView, a consulting firm in Sydney specialising in SharePoint solutions, products (WISDOM Document Management extensions, Custom Search solutions) and consulting around Enterprise Search. My background includes experience developing solutions in VB, VB.Net C#, ASP, ASP.Net, SharePoint (from V1) and Office.

Need SharePoint Training? Attend a SharePoint Bootcamp!

Posts (c) their respective authors. Everything else (c) 2007 SharePoint Experts