0

I need to set some properties in the timer job property bag
In the FeatureActivated event I use this code to set the property:

MyJob job = new MyJob (JobName, webApp);    
// Set my custom property!
job.Properties.Add("test", "test value");    
SPHourlySchedule schedule = new SPHourlySchedule();
schedule.BeginMinute = 0;
schedule.EndMinute = 59;
job.Schedule = schedule;   
job.Update();

Then in the Execute method of the timer job I use this to get the property:

public override void Execute(Guid targetInstanceId)
{
    try
    {
        // read my coustom property
        var test = this.Properties["test"].ToString();

But I have no properties. (Properties.Count = 0)
I tried to restart the Timer Service several times.

  • Have you reset the SharePoint Timer Service? After updating timer job. – George Norberg Jul 3 '15 at 12:17
  • What is the scope of your feature? – Kalpesh Vaghela Jul 3 '15 at 12:22
  • It is Web Application. The timerjob but the bag is empty – Nk SP Jul 3 '15 at 12:23

Your Answer

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

Browse other questions tagged or ask your own question.