SharePoint 2016 Custom Timer Job Not Showing in Job Definition

452 views Asked by At

I am stuck into something really strange behavior of SharePoint. I have a SharePoint 2016 farm solution. which contains 5 timer jobs classes. When I change something in any job class. all of the sudden any one of these 5 jobs stop showing in job definition. and after 1 month it again start to show up in the definition. Moreover, if I create a new solution and create any job in it and deploy, it also doesn't show up in the job definition.

List of jobs

Job definition

1

There are 1 answers

0
MMUNEEBALI On

Are you using Feature EventReviever to add and configure the Job in Job Definitions?

Feature Event Receiver SP Timer Job Job

This will add the job in Jobs Definition Section and Deactivating Feature will Remove the Job if you activate the Feature.

public override void FeatureActivated(SPFeatureReceiverProperties properties)
    {
        try
        {
            SPSecurity.RunWithElevatedPrivileges(delegate ()
            {
                SPWebApplication parentWebApp = (SPWebApplication)properties.Feature.Parent;
                DeleteExistingJob(JobName, parentWebApp);
                CreateJob(parentWebApp);
            });
        }
        catch (Exception ex)
        {
            throw ex;
        }
    }

public override void FeatureDeactivating(SPFeatureReceiverProperties properties)
    {
        lock (this)
        {
            try
            {
                SPSecurity.RunWithElevatedPrivileges(delegate ()
                {
                    SPWebApplication parentWebApp = (SPWebApplication)properties.Feature.Parent;
                    DeleteExistingJob(JobName, parentWebApp);
                });
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
    }

If this is not the issue and you have a Feature Event Reciever then share the cs file here.