Missing properties on the SPFieldLink?


  • The SPFieldLink maps to the FieldRef XML Tag in the Content type CAML. In the XML version you can set several attributes; ShowInDisplayForm, ShowInNewForm, ShowInEditForm, etc.

    When looking at the SPFieldLink, only the ShowInDisplayForm has been exposed as a public property.

    The class itself has a bunch of member variables; n_bShowInEditForm, m_bShowInNewForm, m_bShowInFileDlg


    Is there a particular reason for why these fields haven't been exposed as public properties? Why only the ShowInDisplayForm?

    The object model should be extended so that it provides the same capabilities as the CAML version.
    Monday, October 24, 2011 8:23 AM

All replies

  • If i got you right, you mean to say FieldRef XML tag for SPFielLink doesn't have ShowInEditForm and ShowInNewForm attributes. Check this out.
    Raghavendra Shanbhag | Blog:
    Please click "Propose As Answer " if a post solves your problem or "Vote As Helpful" if a post has been useful to you.
    Disclaimer: This posting is provided "AS IS" with no warranties.
    Monday, October 24, 2011 9:11 AM
  • The problem is that you can do stuff in XML that you cannot do in code.

    In XML you can set ShowInNewForm = TRUE, but this isn't possible using the object model.

    Using .NET reflector, you can see that the class has backing fields for a whole bunch of settings that haven't been exposed as properties.


    I would like the same capabilities from code as is available in XML.


    The property you referenced is read-only, so I can't set anything that way.
    Monday, October 24, 2011 10:49 AM
  • Hi christopher.kimbell,

    The SPFieldLink is an object that present the references between a content type and fields(site columns).

    In order to set a visibility for field, we need to set the properties in the SPField object directly. Or, please set the properties in a field in a list.
    That is why there is no ShowInEditForm, ShowInNewForm in SPFieldLink in my opinion.

    Also, why we can set the properties in SchemaXML? It is because of the SchemaXML is refered to a Field object.

    Jinchun Chen

    Jinchun Chen
    Forum Support
    Please remember to mark the replies as answers if they help and unmark them if they provide no help. If you have feedback for TechNet Subscriber Support, contact tnmff AT replace AT with @)
    Tuesday, October 25, 2011 9:04 AM
  • Ok.......

    In XML it's possible to define the field in one set of XML (<Field/>), and reference these fields in content type XML (<FieldRef/>). In the content type reference, it's possible to override some of the values defined on the XML field.

    With XML it's then possible to define a generic field, and based on what content type it's included in, decide what forms it should be available on.

    Setting the properties on a field in a list is not an option. It must be possible to define the content type correctly in the gallery so that when it's added to a list, all the fields are configured correctly. 

    Why is there a ShowInDisplayForm property? Why is that type of form elevated above the edit and new form? As it is now, it looks like the object model is incomplete.
    Tuesday, October 25, 2011 9:47 AM
  • 3 years later, but I have crash with the same problem. 

    Trying to change the Content Type definition (ShowInEditForm) with Powershell, I have continuous errors "Property not found for this object...." and so on.

    I was trying to avoid the embarrassment of working with Upgrading Features on Lists with Definition ---> C.Type --> Site columns schema.

    I think it's an unfinished work on this class by the SharePoint Team.

    Thursday, October 09, 2014 7:45 AM