SharePoint: temporary solution for GetCustomProperty and SetCustomProperty errors

Another day, another kinky problem with SharePoint. This time I struggled with custom properties of my custom field. I tried out different code samples to make GetCustomProperty and SetCustomProperty to work but no luck at all – nothing worked for me. There was no errors when adding field to list or changing field properties but custom properties were never saved. I don’t like solutions like my version comments solution but some (not only some, sorry) parts of SharePoint need brutality and violence to work like expected. But I have solution.

 

NB! This blog is moved to gunnarpeipman.com

Click here to go to article

9 Comments

  • oooo thanks. i seacrhing to these codes at google

  • Thanks, i have been looking for this all day long, and yesterday also !!

    This solution finally works.

    Bit strange though that you need reflection to accomplisch something simple as storing some values.

  • Hi Can I achieve the same stuff outside this Field class.

    I have a fieldAdded event and I'm trying getcustomproperty there.....and it sometimes work and sometimes it returns null value.

    Please mail back to me at
    manu_khullar@infoys.com if you have a solution.

    Thanks
    Manu

  • Hi Can I achieve the same stuff outside this Field class.

    I have a fieldAdded event and I'm trying getcustomproperty there.....and it sometimes work and sometimes it returns null value.

    Please mail back to me at

    manu_khullar@infosys.com if you have a solution.

    Thanks

    Manu

  • Thanks.. works like a charm! Have seen a few solutions around for this issue - nothing as clean/simple as this.

  • Thanks for good words Jimmy! :)

  • I had SetCustomPropery working with a little help from ReadUnreaColumn on Codeplex.

    Then my SSD failed while backing up the source!!!

    I re-wrote it and just couldn't get Set/GetCustomProperty to work -- your work here has got me out of a big hole - many thanks.

    What I've said in my earlier post remains true but there's another nasty thing going on here.

  • Thanks for feedback, Daniel!

    You are almost correct: yes, in thoery property schema should help you. In practice there are versions when this does not hold true. As some of your customers may face this problem you know the solution what to do. :)

  • Thank you Gunnar, without wanting to sound strange, I could kiss ya! I've spent two days trying to sort that out. Using Reflection is a bit annoying, but it's a tidier solution that what we had been trying!

    Oh, and for Daniel above - my XML already contained my properties, but I still had the issue this solves.

Comments have been disabled for this content.