Below you will find pages that utilize the taxonomy term “SPFeature”
Posts
Add global navigation links in Powershell and Feature Receiver
I think, powershell is the best way to do configurations you have to do once. Adding some links to global (top) navigation is one of them:
asnp microsoft.sharepoint.powershell $w = get-spweb http://takana $l = New-Object Microsoft.SharePoint.Navigation.SPNavigationNode("Smells like team spirit", "/pages/teamspirit.aspx") $w.Navigation.TopNavigationBar.AddAsLast($l) Feature receiver The alternative is to create a web scoped feature and provide properties:
public override void FeatureActivated(SPFeatureReceiverProperties properties) { var web = properties.Feature.Parent as SPWeb; var prop = properties.
Posts
Retention policies
Ziegler provides a cool intro, implementation sample and much more. When deployed we can apply this policy to a contenttype in the UI, or in code. To create our own expiration logic we have to implement IExpirationFormula and its ComputeExpireDate:
public class TaskExpiration : IExpirationFormula { public DateTime? ComputeExpireDate(SPListItem item, XmlNode parametersData) { if (!item\["Status"\].Equals("Completed")) { return null; } var dt = (DateTime) item\["Modified"\]; return dt.AddDays(30); } } ```In order to see IExpirationFormula, add a reference to Microsoft.
Posts
Uninstall custom features in a batch
A funny powershell command I came upon today together with my colleague. Remove all your custom features (which start with something, say contoso):
Get-SPFeature | Where { $\_.DisplayName.StartsWith("Contoso.") } | ForEach { Uninstall-SPFeature $\_.Id -confirm:0 -force } Have fun!