Hidden Field Content Types

Recently I was working on a event handler that was triggered when an item in the host list was approved. I needed to prevent the event from being actioned if an item had been approved previously. To do this I had to create a hidden flag field in the list that could be set and queried by the event handler but was not visible or set-able by users of the list.
Below is an example of the two features I created in order to “deploy” the hidden field content type. One details the new field type and the other details the field content type.
 

<?xml version=”1.0″ encoding=”utf-8″ ?>
<Elements xmlns=”http://schemas.microsoft.com/sharepoint/“>
<Field ID=”{DA7A42EE-CDD5-4ec4-A641-2D773B320DA7}”
        Name=”ImmediateSent”
        SourceID=”http://schemas.microsoft.com/sharepoint/v3
        StaticName=”ImmediateSent”
        Group=”ImmediateSent”
        Type=”Boolean”
        ShowInNewForm=”FALSE”
       
ShowInEditForm=”FALSE”
       
ShowInDisplayForm=”FALSE”
        DisplayName=”ImmediateSent” >
<Default>0</Default>     
</Field>
</Elements>

 

<?xml version=”1.0″ encoding=”utf-8″ ?>
<Elements xmlns=”http://schemas.microsoft.com/sharepoint/“>
    <ContentType ID=”0x0100D76B3817D18C4a97D3B1742271806CCF”
        Name=”Hidden Flag”
        Group=”ImmediateSent”
        Description=”Designed to allow an a boolean field to be hidden.”
        Version=”0″>
        <FieldRefs>
            <FieldRef ID=”{DA7A42EE-CDD5-4ec4-A641-2D773B320DA7}” Name=”ImmediateSent” />
        </FieldRefs>
    </ContentType>
</Elements>

It is important to activate the field feature first and then the content type feature as it references the new field.
Once activated, I just navigated to the list and added a column from the existing site columns and selected the ImmediateSent column.
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s