locked
Media Asset Library - ListCreationInformation.TemplateType? RRS feed

  • Question

  • A Digital Asset Library should have a TemplateType which is an integer value. ListCreationInformation.TemplateType requires an integer value however the ListTemplateType enumeration does not have a value for Media Assets. Using 101 I can programatically create a document library but it does not have the ContentTypes of a Media Assets library. 

    What is the integer value to create an Assets Library without having to manually retrieve the Video, Audio and Image Content Types from the site and add them manually?

    Tuesday, August 23, 2011 10:36 AM

Answers

  • Yeah.. i understand what you mean. Well when you get the xml from client object model .. are you sure you are trying to get the property in the success function of the query, because until the query is executed you cannot get the values of the property of an object.
    "T" | community.zevenseas.com/Blogs/Tanmay/default.aspx
    • Marked as answer by Shimin Huang Friday, September 2, 2011 6:50 AM
    Thursday, August 25, 2011 7:21 AM

All replies

  • I guess one thing that you can do is ... so the SP.ListCollection object does have a method to to get the site default Asset library http://msdn.microsoft.com/en-us/library/ff408213.aspx .. you can use that go get the the list and use the basetemplate or template type or xml schema of this asset library to create the new list using the liscreationinformation object.... hope that makes sense!!
    "T" | community.zevenseas.com/Blogs/Tanmay/default.aspx
    Tuesday, August 23, 2011 11:01 AM
  • Try 851.

     


    Darrin Bishop Aptillon, www.aptillon.com
    Tuesday, August 23, 2011 12:17 PM
  • After creating an Assets Library by hand then programatically checking the BaseType it is indeed 851. However SharePoint throws "Invalid List Template" when I apply that to ListCreationInformation.TemplateType. I can apply 851 to ListCreationInformation.DocumentTemplateType but this does not give me a Library that in any way behaves any differently than a base Document Library.

    I tried getting the SchemaXml string from the Assets Library I created by hand but that property is not initialized when I retrieve the list for inspection.

    What I need is a snippet that shows me how to create a Media Assets library in code that behaves like an Assets Library in SharePoint 2010. In other words it opens in thumbnail view, has Image, Audio, Video content types and supports drag operations into other Office 365 applications just like the Assets Library you can create by choosing More Options... and pick Asset Library from the Silverlight applets.

    I am at a loss as to why there is nothing in the ListTemplateType enumeration to support an Asset Library. MS has made such a big deal out of this feature and then seemingly has completely overlooked the development side of it? This should be an easy thing to accomplish. Any additional help would be appreciated.


    Eric Kleeman
    Thursday, August 25, 2011 5:07 AM
  • Yeah.. i understand what you mean. Well when you get the xml from client object model .. are you sure you are trying to get the property in the success function of the query, because until the query is executed you cannot get the values of the property of an object.
    "T" | community.zevenseas.com/Blogs/Tanmay/default.aspx
    • Marked as answer by Shimin Huang Friday, September 2, 2011 6:50 AM
    Thursday, August 25, 2011 7:21 AM
  • Yes, unfortunately I check for the property after the async query. I even tried explicitly asking for it with an include clause in the load method but it would not allow me to use that syntax on a list like you can a listcollection.

    Anyway I'm not even sure the XML schema would achieve what I want. I was able to simulate an Asset library by just adding a Video content type but the resulting list does not show up in the thumbnail view and does not seem to support the dialog that you get when you mouse over a video in an Asset Library. Also, it does not seem to support drag operations. It also fails to show the thumbnail preview in the list when you show that column. I'm wondering what the point of built in content types really is if you can create one on the fly with the same fields and it behaves the same. In Silverlight, it is about the same number of async calls to pull a content type as it is to just build one on the fly. So why bother.

    The bummer is if I can't get this working I'll have to tell customers they will have to create an asset library by hand if they want those features then add the additional columns I need which is lame.


    Eric Kleeman
    Thursday, August 25, 2011 9:19 AM
  • yes, you must set 851 for ListTemplateType, but not enough, you also must set the TemplateFeatureId parameter, and that is the GUID for asset library.
    • Proposed as answer by lionel limozin Monday, November 5, 2012 1:13 PM
    Tuesday, May 29, 2012 5:52 AM
  • the template id is 851, and as kenny said, you must also specify TemplateFeatureId !

    Here is a sample using scom :

    ClientContext ctx = new ClientContext(WebUrl);
    ListTemplateCollection spListsTemplates = ctx.Web.ListTemplates;
    ctx.Load(spListsTemplates);
    ctx.ExecuteQuery();
    var SelectedTemplate = spListsTemplates[0];
    ListCreationInformation lc = new ListCreationInformation();
    lc.Title = "temp " + SelectedTemplate.Title;
    lc.TemplateType = SelectedTemplate.ListTemplateTypeKind;
    lc.TemplateFeatureId = SelectedTemplate.FeatureId;
    List newList = ctx.Web.Lists.Add(lc);
    ctx.ExecuteQuery();


    Blog Sharepoint : www.paslatek.net Twitter : @LimozinLionel

    • Proposed as answer by lionel limozin Monday, November 5, 2012 1:16 PM
    Monday, November 5, 2012 1:16 PM
  • you must set 851 for ListTemplateType and set TemplateFeatureId parameter(GUID) for asset library.
    • Proposed as answer by Sharique Ansari Wednesday, January 23, 2013 10:43 AM
    Wednesday, January 23, 2013 10:13 AM
  • The previous sample assumes that an asset library already exists to derive the Feature ID and Template Type values from.  Here is a complete SharePoint 2013 client object model code sample for creating an Asset Library by setting the Feature ID and Template ID explicitly:

    CLientContext ctx = new ClientContext("http://sitename");
    Web web = ctx.Web;
    ctx.Load(web);
    ctx.ExecuteQuery();
    ListCreationInformation creationInfo = new ListCreationInformation();
    creationInfo.Title = "My Asset Library";
    creationInfo.TemplateType = 851;
    creationInfo.TemplateFeatureId = new Guid("4BCCCD62-DCAF-46dc-A7D4-E38277EF33F4");
    List list = web.Lists.Add(creationInfo);
    list.Description = "Asset Library created with the Client Object Model";
    list.Update();
    ctx.ExecuteQuery();

    Saturday, June 1, 2013 1:54 AM