how to set default content type in document set in Sharepoint
2014-09-12 17:34
711 查看
I had encounter a issue when set default content type in document set, had to work around it
Create a custom document set in library, besides I want the document set only contains a content type I want to use, hence add a custom content type in the document set, and remove the default "Documen"t type. finally, there will be only one content type,
but, when upload document in the document set, it is not working, it still had the content type named "Document", even it is the default content type, it is a bug in sharepoint, that is not my expected. I have to work around it.
this is default content type in sharepoint,
but what I expected is it:
2. besides, I found that the url had no content type id in the first open uploading dialog,so we just apppend the content tyepe id after the url when open the uploading dialog.
Document content type)
2. Add Script Web Part in EditForm of KnowledgeLibrart
2. Javascript change the content type
Create a custom document set in library, besides I want the document set only contains a content type I want to use, hence add a custom content type in the document set, and remove the default "Documen"t type. finally, there will be only one content type,
but, when upload document in the document set, it is not working, it still had the content type named "Document", even it is the default content type, it is a bug in sharepoint, that is not my expected. I have to work around it.
this is default content type in sharepoint,
but what I expected is it:
1. here is my thinking:
1. observe that the href is alway changing when switch the content type in uploading, the only changed is the content type id in url, so we just update the content type id and navigate the new locatio href, it will be working.2. besides, I found that the url had no content type id in the first open uploading dialog,so we just apppend the content tyepe id after the url when open the uploading dialog.
2. here is my steps
1. create a document library named "KnowledgeLibrary", and create some document sets, at this time, each of the document set has the only and correspond content type(For example: DocumentSetA, DocumentSetB, ContentTypeA, ContentTypeB, and the id of defaultDocument content type)
2. Add Script Web Part in EditForm of KnowledgeLibrart
<script> $(function(){ var locationUrl = location.href; var rootFolder = ""; var contentTypeId = ""; rootFolder = locationUrl.substring(locationUrl.indexOf("RootFolder"),locationUrl.length); rootFolder = rootFolder.substring(0 ,rootFolder.indexOf("&")); contentTypeId = locationUrl.substring(locationUrl.indexOf("ContentTypeId"),locationUrl.length); contentTypeId = contentTypeId.substring(0 ,contentTypeId.indexOf("&")); if(locationUrl.indexOf("ContentTypeId") < 1){ rootFolder = rootFolder.substring(rootFolder.indexOf("KnowledgeLibrary%2F")+19); if(rootFolder.indexOf("%2F")>0){ rootFolder = rootFolder.substring(0, rootFolder.indexOf("%2F")); } // document content type id for default content type var contentDefaultID= "0x010100579C194BB641F9459CFD192AF39DC1FE"; console.log("rootFoldr :" + rootFolder); switch(rootFolder){ case "DocumentSetA" : contentDefaultID= ContentTypeAId; break; case "DocumentSetB": contentDefaultID= ContentTypeBId; break; default: contentDefaultID= "0x010100F3FA1C5131EDFB4A90F1E96FAF0F8B9F"; break; } location.href = locationUrl + "&ContentTypeId=" + contentDefaultID; console.log(location.href); } }); </script>
3. here is the result:
1. it is defalut document content type in begin loading2. Javascript change the content type
相关文章推荐
- SD --- How to set a default condition type in sales order
- How to use document library in Sharepoint 2010
- sharepoint ECMA using a custom contentType to creating a list in SubSite
- How to hide my site and my document link in the right-top corner of sharepoint 2010
- How to Enable or Disable Document Property Promotion (ParserEnabled) in SharePoint 2013
- How to set Item Level Permission for SharePoint 2007 (MOSS/WSS) List/Document Library Programmatically
- How to create your own custom 404 error page and handle redirect in SharePoint 2007 (MOSS)?
- How to Export & Import Web Parts in SharePoint(转)
- How to set value for webpart’s properties when I create a new sharepoint template
- How to change service accounts and service account passwords in SharePoint Server 2007 and in Windows SharePoint Services 3.0(Se
- Think in SharePoint 2010 OOTB Project: Site Columns & Site Content Type
- 学习:How To Use Filters in SharePoint to show items in the current Calendar Month(转)
- How to Create Multilingual Webpart in SharePoint 2010? Use Localization in Globalization.
- How to change service accounts and service account passwords in SharePoint Server 2007 and in Windows SharePoint Services 3.0
- How to submit an InfoPath form to a Windows SharePoint Services document library
- 转:How to force a wordbreaker to be used in Sharepoint Search
- [转]How to Create a Thumbnail Picture Library View in SharePoint 2007
- 转:How to submit the rows of a repeating table in InfoPath to a SharePoint list
- How to set user-defined-type as Oracle SP input parameter in .NET
- how to find sharepoint app pool in win server2008?