Disasterkid Disasterkid - 27 days ago 12
C# Question

Can JobKey be changed? How?

What are the dangers of changing a

JobKey
without tampering with its schedule? And how can we do it? I suppose we should change the associated triggers with it as well, right?

Answer

It would be a different job so you would have to:

  • Retrieve the job with the old JobKey and call scheduler.DeleteJob(key) since you want both the JobDetail and Trigger removed.
  • Reschedule with your new JobKey and the old schedule.

However, since a campaign has an Id you can use that as a JobKey, the assumption here being that an Id will not change. If it's important for users to identify jobs by their campaign name, you can build a new JobDetail with similar parameters as the existing one, but change the Description to match the new campaign name and then call:

 scheduler.AddJob(jobDetail, true)

which should replace the old JobDetail with the new one.