Advertisement
Guest User

Untitled

a guest
Oct 6th, 2015
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.02 KB | None | 0 0
  1. Web web = context.Web;
  2. // 1. Create a New list
  3. web.Lists.Add(new ListCreationInformation
  4. {
  5. Title = lstTitle,
  6. Description = lstDesc,
  7. Url = "Lists/" + lstTitle,
  8. TemplateType = (int)ListTemplateType.GenericList,
  9. // TemplateFeatureId = new Guid(lstGuid),
  10. });
  11.  
  12. context.ExecuteQuery();
  13. // 2. Associate custom content Type with List
  14. context.Load(context.Web, w => w.ServerRelativeUrl);
  15. context.ExecuteQuery();
  16.  
  17. Microsoft.SharePoint.Client.List configListCT = context.Web.Lists.GetByTitle(lstTitle);
  18. ContentType lookupContentType = context.Web.AvailableContentTypes.GetById(CTGuid);
  19.  
  20. configListCT.ContentTypesEnabled = true;
  21. configListCT.ContentTypes.AddExistingContentType(lookupContentType);
  22. configListCT.Update();
  23. // Error occurs: Value does not fall within the expected range
  24. context.ExecuteQuery();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement