Skip to content

Instantly share code, notes, and snippets.

@AsishP
Last active January 25, 2018 06:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AsishP/864d19ecb61c57ce317bd7d3fda87e1c to your computer and use it in GitHub Desktop.
Save AsishP/864d19ecb61c57ce317bd7d3fda87e1c to your computer and use it in GitHub Desktop.
ListTemplateCollection templates = context.Site.GetCustomListTemplates(context.Web);
context.Load(templates);
context.ExecuteQuery();
log.Info("Templates Loaded");
// Initialize list or library creation info
var template = templates.First(listTemp => listTemp.Name == "<name of template>");
var listCreationInfo = new ListCreationInformation();
listCreationInfo.Title = LibName;
listCreationInfo.Description = LibName;
listCreationInfo.ListTemplate = template;
listCreationInfo.TemplateFeatureId = template.FeatureId;
listCreationInfo.TemplateType = template.ListTemplateTypeKind;
// Add Document Library to site
LibNew = context.Web.Lists.Add(listCreationInfo);
context.ExecuteQuery();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment