Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I using following code to change AlertTemplate for a list. But it dosen't work. When I look at the XML for the template variable it's the correct XML. But when I look att list.AlertTemplate after that I have set the template object to it, it's XML is still unchanged. What should I do for to solve it?

                XmlDocument xmlDoc = new XmlDocument();
                xmlDoc.Load(SPUtility.GetGenericSetupPath(@"TEMPLATE\XML") + "\\SubscribeOrdersAlert.xml");
                try
                {
                    SPList list = site.RootWeb.GetList("/Lists/Tillggsbestllningar");
                    SPAlertTemplate template = new SPAlertTemplate();
                    template.Xml = xmlDoc.InnerXml;
                    template.Name = "Tilläggsbeställningar";
                    list.AlertTemplate = template;
                    list.ParentWeb.AllowUnsafeUpdates = true;
                    list.Update();
                }
share|improve this question
    
I have found out that I needed to add the alert template to the SPAlertTemplateCollection. But when I do it I get "Access denied" sPAlertTemplateCollection.Add(template); –  Daniel Jan 18 '12 at 11:41
add comment

1 Answer

up vote 0 down vote accepted

I deployed the xml with a stsadm-command and then it worked.

stsadm -o updatealerttemplates- url http://mysite.com -filename c:\SubscribeOrdersAlert.xml
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.