how to set default content type in document set in Sharepoint

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 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 loading

2. Javascript change the content type

时间: 2024-10-06 00:31:33

how to set default content type in document set in Sharepoint的相关文章

转载 SharePoint【Site Definition 系列】– 创建Content Type

转载原地址:  http://www.cnblogs.com/wsdj-ITtech/archive/2012/09/01/2470274.html Sharepoint本身就是一个丰富的大容器,里面存储的所有信息我们可以称其为“内容(Content)”,为了便于管理这些Conent,按照人类的正常逻辑就必然想到的是对此进行“分类”.分类所涉及到的层面又必然包括: 1.分类的标准或特征描述{即:类型属性(或:与该类型项目相关联的属性)}. 2.对应类的关联动作(即:工作流,行为以及其他设置)  

org.springframework.web.HttpMediaTypeNotSupportedException: Content type &#39;application/json;charset=UTF-8&#39; not supported

踩到了一个神坑,明明@RequestMapping注解并没有设置consumes,即没有限定请求参数的类型.却出现文章底部的错误,原因竟然是同一个model下注解了两个@JsonBackReference. @Entity // 用户 public class User extends IDomain { @Column(columnDefinition = "varchar(255) comment '[电话]'") private String phone; @Column(col

Jsoup问题---获取http协议请求失败 org.jsoup.UnsupportedMimeTypeException: Unhandled content type. Must be text/*, application/xml, or application/xhtml+xml.

Jsoup问题---获取http协议请求失败 1.问题:用Jsoup在获取一些网站的数据时,起初获取很顺利,但是在访问某浪的数据是Jsoup报错,应该是请求头里面的请求类型(ContextType)不符合要求. 错误信息: Exception in thread "main" org.jsoup.UnsupportedMimeTypeException: Unhandled content type. Must be text/*, application/xml, or applic

Jsoup获取部分页面数据失败 org.jsoup.UnsupportedMimeTypeException: Unhandled content type. Must be text/*, application/xml, or application/

用Jsoup在获取一些网站的数据时,起初获取很顺利,但是在访问某浪的数据是Jsoup报错,应该是请求头里面的请求类型(ContextType)不符合要求. 请求代码如下: private static void testOuGuanMatch() throws IOException{        Document doc = Jsoup.connect("我的URL").userAgent("Mozilla/5.0 (Windows; U; Windows NT 5.1;

Spring MVC 前后台传递json格式数据 Content type &#39;application/x-www-form-urlencoded;charset=UTF-8&#39; not supported

报错如下: Content type 'application/x-www-form-urlencoded;charset=UTF-8' not supported 解决方案: 引入如下包: 问题既解决. Spring MVC 前后台传递json格式数据 Content type 'application/x-www-form-urlencoded;charset=UTF-8' not supported

InfoPath与SharePoint之(六)在表单库里引用InfoPath Form Content Type

在表单库里引用InfoPath Form Content Type 在上一篇,介绍了如何把InfoPath Form类型的Content Type发布到SiteCollection,发布完之后,就可以在已经存在的表单库里引用了. 打开一个已经存在的表单库,点击Ribbon上的Library Settings: 在Settings页面,点击Advanced Settings: 默认情况下,添加Content Type功能是关闭的,在这里开启: 再回到Library Settings页面,就可以添加

InfoPath与SharePoint之(五)发布InfoPath表单到Content Type

不管是在List里定制化表单,还是发布表单到Library,都有一个缺陷,就是不能被其他的List/Library重复使用. 因此SharePoint提供了一个功能,可以把表单发布成Content Type,这样其他的List/Library就可以引用它了. 打开之前设计的一个表单: 选择发布到SharePoint Server: 输入一个Site 的URL: 在类型这里,选择Content Type: 选择创建一个新的Content Type.如果以前发布过这个Content Type,现在要

the request doesn&#39;t contain a multipart/form-data or multipart/form-data stream, content type header

the request doesn't contain a multipart/form-data or multipart/form-data stream, content type header 一,HTTP上传的基本知识 在Form元素的语法中,EncType表明提交数据的格式 用 Enctype 属性指定将数据回发到服务器时浏览器使用的编码类型.下边是说明: application/x-www-form-urlencoded: 窗体数据被编码为名称/值对.这是标准的编码格式. mult

org.springframework.web.HttpMediaTypeNotSupportedException: Content type &#39;application/json;charset=UTF-8&#39; not supported或其他Content type不支持处理

很久没从头到尾搭框架,今天搭的过程中,springmvc controller方法入参用@RequestBody自动绑定参数时一直提示各种 not supported 排查问题有两个解决路径: 1)使用post协议提交时,请检查Content type类型,如: $.ajax({ type: "POST", contentType: "application/json;charset=UTF-8", url: "/reg", data: JSON