开发者

Sharepoint Document Library Schema.xml Customization

Hi I am trying to add a custom field to the Schema.xml of Document library in sharepoint

here is the code that I took from a blog

In the ID i have to put the guid to do so do I have to add my own guid or do i have to query the sharepoint database and find the guid and paste it there...

If i have to get it from sharepoint database which database and in what table I will find this information...开发者_如何学JAVA.

any help will be greatly appreciated

Thanks, srikrishna.


This is now a duplicate post from MSDN forms

http://social.technet.microsoft.com/Forums/en-US/sharepointcustomization/thread/72df8c80-9e58-4c09-b1a6-ddfe1fb96b0a


there is a sure and safe mean :

1 - create a list with the SharePoint UI

2 - add a column to the list within the SharePoint UI

Create an applicative page that gets the schema of the list and you are done :

SPList mylist=SPContext.Current.Web.Lists["myNewList"]; 

string schema = mylist.SchemaXml; 
schema = schema.Replace("<", "&lt;");
schema = schema.Replace(">", "&gt;"); 

string myAddedColumnSchema = mylist.Fields["MyAddedColumn"].SchemaXml; 
myAddedColumnSchema = myAddedColumnSchema .Replace("<", "&lt;");
myAddedColumnSchema = myAddedColumnSchema .Replace(">", "&gt;"); 

Response.Write(schema);

Response.Write("<br>");
Response.Write("<br>"); Response.Write(myAddedColumnSchema );

Response.Write("<br>");
Response.Write("<br>");

This gives you the schema of the list with the field, and also just the field row in the list schema (of course copy the result in Visual Studio and use "Format Document" because on the web page it is just unreadable. You cannot use this list schema by copying and pasting it in a SharePoint 2010 list Schema but you can locate the place where put the XAML correponding to your custom field.

After that you have to create a custom Content Type just for your custom field. With SharePoint 2007 you could put a local content type corresponding to the custom field within the list schema but IT IS OVER. (I think... if someone can do it I will be pleased to be wrong ;-))

Then install the list feature with the new schema, and activate it within a site. Then install the Content Type feature and activate it. Then create a list based on the new schema, allow content type gestion for that list and add the new content type. All the items based on the new content type will be allowed to use the new field.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜