Wednesday, June 12, 2013

SharePoint 2010 Custom Field Control, Lookup, Custom Content Type, Custom Page Layout

Step by Step guide to create content type and page layout including lookup column:

1. Create "Empty SharePoint Project"
2. Add a "Empty Element" file
3. Add "Field" in empty Elements tags. like for link list:

   
         EnableLookup="TRUE"
          Name="FieldName"
          DisplayName="Name you would like to display to end  user"
          Type="Lookup"
          Group="group name"
          Description="enter description for end user here"
          Overwrite="TRUE" --This is very important if you have form solution, as other you will get error, ignore in case of sandbox solution.
         List="Lists/ListName"
          ShowField="ColumnName"/>

For normal column add details like

   
          Name="FieldName"
          DisplayName="Name you would like to display to end user"
          Type="Text" -- Mention type here like text, note, datetime
          Group="group name"
          Description="enter description for end user here"/>   
4. Add New Item - Content Type
This opens SharePoint customization Wizard -  choose base content type you wants to inherit
5. In Newly added content type file under "FieldRefs" add "FieldRef" with values from fields added in step 3.

ex.

       
       Name="namesame as mentioned in field"
       DisplayName="display name same as mentioned in field"
       Description="description for end user"/>

6. Add new item module

7. Delete file sample.text and add .aspx file.

8. Element file under page layout folder should be look like

 
     
         
              Value="$Resources:cmscore,contenttype_pagelayout_name;"/>
         
                    Value=";#name from conent type under tag content type ;#id from content type under tag contenttype;#"/>
         
                    Value="name of page layout"/>
     

Publish and enjoy....

No comments: