Tuesday, 1 July 2014

How to Delete SPJobDefinition in Sharepoint using Object Model Code

const string strFeatureName="My Job";
public override void FeatureActivated(SPFeatureReceiverProperties properties)
{
foreach (SPJobDefinition job in (properties.Feature.Parent as SPWebApplication).JobDefinitions)
{
if (job.Name == strFeatureName)
{ job.Delete(); }
}
}