how to set default content type in document set in Sharepoint
来源:互联网 发布:java 私有构造方法 编辑:程序博客网 时间:2024/06/15 20:21
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:
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 default Document 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 typevar 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 loading
2. Javascript change the content type
- how to set default content type in document set in Sharepoint
- How to set default values for IBInspectable in Objective-C?
- How to set the style in valuelist
- How to use SET in python
- How to Set isIgnorePagination in Jasper Report
- How can I set default terminal used in Unity?
- How to use document library in Sharepoint 2010
- applicationId is set to 'com.super.app' in default config
- How to set NULL to a pointer in Managed C++?
- How to convert ArrayList to Set in Java with Example
- android studio 1.0 Library projects cannot set applicationId. applicationId is set to '' in default
- Error: Library projects cannot set applicationId. applicationId is set to '包名' in default
- HOW TO: Set a Windows Hook in Visual C# .NET
- HOW TO: Set a Windows Hook in Visual C# .NET
- How to set background image of a component in GWTEXT
- How to: Set a Thread Name in Native Code
- How to set network proxy for terminal in Ubuntu
- How To Set Up Database Replication In MySQL On Ubuntu
- python通过图片内容判断图片类型
- Windows下的mingw32显示中文
- HTML----表单中隐藏域小结
- 30款免费的手机UI设计资源
- Android采用KSOAP2访问webservice
- how to set default content type in document set in Sharepoint
- java各种排序算法
- 让jar程序在linux上一直执行
- GridLayout,TableLayout
- Combination Sum II
- Extjs动态加载树
- sgu 176 Flow construction (有汇源有上下界的最小流)
- Found 3 versions of android-support-v4.jar in the dependency list
- SQL 建立数据库 表