Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Web web = context.Web;
- // 1. Create a New list
- web.Lists.Add(new ListCreationInformation
- {
- Title = lstTitle,
- Description = lstDesc,
- Url = "Lists/" + lstTitle,
- TemplateType = (int)ListTemplateType.GenericList,
- // TemplateFeatureId = new Guid(lstGuid),
- });
- context.ExecuteQuery();
- // 2. Associate custom content Type with List
- context.Load(context.Web, w => w.ServerRelativeUrl);
- context.ExecuteQuery();
- Microsoft.SharePoint.Client.List configListCT = context.Web.Lists.GetByTitle(lstTitle);
- ContentType lookupContentType = context.Web.AvailableContentTypes.GetById(CTGuid);
- configListCT.ContentTypesEnabled = true;
- configListCT.ContentTypes.AddExistingContentType(lookupContentType);
- configListCT.Update();
- // Error occurs: Value does not fall within the expected range
- context.ExecuteQuery();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement