A Practical Guide to SharePoint 2013

A Practical Guide to SharePoint 2013
A Practical Guide to SharePoint 2013 - Book by Saifullah Shafiq

Thursday, May 4, 2006

Creating your own document library with your own set of fields

Creating your own document library with your own set of fields

You manage a large document management system in your organization. Your organization has many departments. You create a site for each department and each site has a document library. You add some custom fields in your library but you don't want the dialog box to pop-up asking users to enter values for the custom fields whenever they insert a new document. You may have experienced this in your company. When you add custom fields in your document or form library, a dialog box pops up every time user tries to add a new document. Suppose, the number of custom fields exceeds 10. You don't want your users to be presented with a dialog box with more than 10 fields to be filled up every time they add a file. You need to add these fields in all the document libraries in your SharePoint Portal. What do you do? Go to each library, and add these fields? Not a good solution!! Wouldn't it be nice if all these fields get added to your document library template? This way when you will add a new document library to a site, all the custom fields will already be part of the document library and interestingly, you won't get that dialog box popping up each time a document is added to the library.
Let's create a document library template of our own with the following new fields:
1. Level
2. Workflow
3. Approver
Here are the steps to create a template of our own:
1. Go to following location: C:Program FilesCommon FilesMicrosoft Sharedweb server extensions60TEMPLATE1033STSLISTS
2. Copy "DOCLIB" folder and paste it in the same folder. Rename new folder to "MYDOCLIB"
3. Go to: C:Program FilesCommon FilesMicrosoft Sharedweb server extensions60TEMPLATE1033STSXML. This location contains ONET.XML file.
4. After taking back up of the original file, open ONET.XML and locate the following line:

<ListTemplate Name="doclib" DisplayName="Document Library" Type="101" BaseType="1" OnQuickLaunch="TRUE" SecurityBits="11" Description="Create a document library when you have a collection of documents or other files that you want to share. Document libraries support features such as sub-folders, file versioning, and check-in/check-out." Image="/_layouts/images/itdl.gif" DocumentTemplate="101"></ListTemplate>

Copy and paste the following line underneath the above line:

<ListTemplate Name="mydoclib" DisplayName="My Document Library" Type="899" BaseType="1" OnQuickLaunch="TRUE" SecurityBits="11" Description="This is a customized Document Library. Create a document library when you have a collection of documents or other files that you want to share. Document libraries support features such as sub-folders, file versioning, and check-in/check-out." Image="/_layouts/images/itdl.gif" DocumentTemplate="101"></ListTemplate>

5. Open Schema.xml from the following path:
C:Program FilesCommon FilesMicrosoft Sharedweb server extensions60TEMPLATE1033STSLISTSMYDOCLIB
6. Take backup of the original file before making changes. Locate following code in the schema.xml:
<List xmlns:ows="Microsoft SharePoint" Name="Documents" Title="Shared Documents" Direction="0" Url="Shared Documents" BaseType="1" >
<MetaData>
<Fields>

...
Inside <Fields> tag, you can include your own fields. Add following lines inside <Fields> and </Fields> tags:

<Field Type="Text" Name="Level" ShowInNewForm="FALSE" ShowInFileDlg="FALSE" DisplayName="Level"></Field>
<Field Type="Text" Name="WorkFlow" ShowInNewForm="FALSE" ShowInFileDlg="FALSE" DisplayName="WorkFlow"></Field>
<Field Type="Text" Name="Approver" ShowInNewForm="FALSE" ShowInFileDlg="FALSE" DisplayName="Approver"></Field>

Save schema.xml!
7. Restart IIS.
Now, go to "CREATE" page, you will see two document library templates. Select your newly added template and create a document library. This library will have additional fields by default. You can add as many fields as you like. 

-SSA