3

In my web application level feature, its activated, but unable to see teh timer job in the timerjob definitions, in monitoring so i went with activating feature with powershell, receiving this error:

Getting error while activating timer job feature:

PS C:\Windows\system32> E:\PoCSolutions\enable-feature-TestingTimerJob-Feature.ps1 enable-spfeature : The Feature is not a Farm Level Feature and is not found in a Site level defined by the Url http://srvr1:28516/.

  • enable-spfeature -Identity "TestingTimerJobFeature" -Url "http://srvr01: ...
  • ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    • CategoryInfo : InvalidData: (Microsoft.Share...etEnableFeature:SPCmdletEnableFeature) [Enable-SPFeature], SPCmdletException
    • FullyQualifiedErrorId : Microsoft.SharePoint.PowerShell.SPCmdletEnableFeature

  private bool CreateJob(SPWebApplication site)
      {
          bool jobCreated = false;
         try
        {
            TestingSPTimerJob.TestingSPTimer timerjobrilt1 = new 
            TestingSPTimerJob.TestingSPTimer(JobName, site);  
            SPDailySchedule jobDailySchedule = new SPDailySchedule();
            jobDailySchedule.BeginHour = 24;
            jobDailySchedule.BeginMinute = 02;
            jobDailySchedule.BeginSecond = 1;

            timerjobrilt1.Schedule = jobDailySchedule;
            timerjobrilt1.Update();
         }
        catch (Exception)
        {
            return jobCreated;
         }
         return jobCreated;
      }

######################################################################### public class TestingSPTimer :SPJobDefinition {

      public TestingSPTimer()
        : base()
        {        }

    public TestingSPTimer(string jobName, SPService service)
        : base(jobName, service, null, SPJobLockType.Job)
       {
        this.Title = "Testing SPTimerJob";
       }

      public TestingSPTimer(string jobName, SPWebApplication webapp)
          : base(jobName, webapp, null, SPJobLockType.Job)
       {
        this.Title = "Testing SPTimerJob";
       }

      public override void Execute(Guid targetInstanceId)
      {
        SPWebApplication webApp = this.Parent as SPWebApplication;

        string strwebappname = webApp.Name.ToString();


        foreach (SPSite singleSite in webApp.Sites)
        {
            if (singleSite.ContentDatabase.Id.Equals(targetInstanceId))
            {
                SPList objListProjRequest = 
        singleSite.RootWeb.Lists.TryGetList("TestingTimerJob");

                SPWeb objspweb = singleSite.RootWeb;

               SPListItem singleitemm=   objListProjRequest.Items.Add();

               singleitemm["Title"] = "Testingtimer_" + 
           DateTime.Now.ToString();

               singleitemm.Update();
3

Make sure the following:

  • Provide the Feature Guid rather than its name from feature.xml file
  • You have provided the correct URL.
  • Don't surround the feature with double quotation " as shown below

    Enable-SPFeature –Identity f9ce720e-6473-47c2-142k-9d94582369e –url $Url
    
  • I did the same .but still the timer job is not visible in the "timerjobdefinitipns" list . – userAZLogicApps Jul 6 '17 at 13:16
  • what's your timer job do – Mohamed El-Qassas MVP Jul 6 '17 at 13:21
  • REad the projectcode field values from list , based on a condition - if the target resolution date < todaysdate - then add those projectcode added into generics_list. Then using these project codes, i will navigate to another doc.lib , n apply item level permission on those matching project codes in the doc.lib. – userAZLogicApps Jul 6 '17 at 13:27
  • Do you tried to change the scope from web application to Site – Mohamed El-Qassas MVP Jul 6 '17 at 13:28
  • No, while creating the feature ,i have selected the scope as webapplication. BTW, is there any way i can check the field called " target resolution date" is < todays date ? Without implementing a timer job? I dont think, its possible using a eventreceiver unless someone explicitly update the list. So ,bcoz of this reason , i have chosen timer job to implement this functionality – userAZLogicApps Jul 6 '17 at 13:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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