首页 文章

SharePoint表单库:以编程方式或Stsadm命令将内容类型更改为自定义表单模板

提问于
浏览
1

我有一个自定义网站定义,其中包括一个表单库 . 我有一个在InfoPath中创建的表单模板 . 通过SharePoint功能,我可以部署所有内容,除了我无法弄清楚如何更改表单库的默认表单以指向我在InfoPath中创建的表单 . 我有一个功能,可以部署表单,但我必须手动进入表单库的高级设置,允许内容类型管理,将默认内容类型更改为模板,并删除默认内容类型 .

任何有关如何以编程方式或通过stsadm执行此操作的想法将不胜感激!

科尔比非洲

1 回答

  • 1

    以下是我用来设置列表内容类型的一些代码 .

    void AddContentTypes(SPWeb web)
        {
            //get a reference to content types previously installed
            SPContentType CompanyAContentPage = web.AvailableContentTypes["CompanyA Content Page"];
            SPContentType CompanyAWelcomePage = web.AvailableContentTypes["CompanyA Welcome Page"];
    
            //get list to mess with
            SPList spList = web.Lists["Pages"];
    
            //enable management of content types
            spList.ContentTypesEnabled = true;
    
            //get the content types added to the list (different from the web ones)
            SPContentType newCompanyAPageContentType = spList.ContentTypes.Add(CompanyAContentPage);
            SPContentType newCompanyAWelcomePageContentType = spList.ContentTypes.Add(CompanyAWelcomePage);
            //update list
            spList.Update();
    
            //get a list of content types for the "new" drop down on the list
            List<SPContentType> contentTypeList = new List<SPContentType>();
            contentTypeList.Add(newCompanyAPageContentType);
            contentTypeList.Add(newCompanyAWelcomePageContentType);
    
            //set the content types for the "new" drop down list
            spList.RootFolder.UniqueContentTypeOrder = contentTypeList;
            spList.RootFolder.Update();
        }
    

    与您的问题不完全相同,但我希望它有所帮助 .

相关问题