Monday, May 26, 2014

Event Receiver to create a List based on a custom template and on lookup field

Hello,


What error you are getting? Please post error message here. Is there any lookup column in list template?


Also you need to dispose SPSite and SPWeb as i can see you are not disposing them.



//SPSite site = properties.Feature.Parent as SPSite;
//SPWeb web = properties.Feature.Parent as SPWeb;
SPWeb web = properties.Feature.Parent as SPWeb;
using (SPSite site = new SPSite(web.Site.ID))
{
using (SPWeb rootWeb = site.OpenWeb(site.RootWeb.ID))//change URL here
{
String curListName = properties.ListTitle;
if(curListName == "Seminarliste")
{
SPListTemplateCollection listTemplates = site.GetCustomListTemplates(web);
SPListTemplate siteChangeTemplate = listTemplates["SiteChangeLogListTemplate"];
web.Lists.Add("SITE List", "test", siteChangeTemplate);
}}}





Hemendra:Yesterday is just a memory,Tomorrow we may never see

Please remember to mark the replies as answers if they help and unmark them if they provide no help


No comments:

Post a Comment