CRM : Rescheduling the Update Contract States job

Update Contract States job is CRM 2011 (also for CRM 4.0) system job which runs daily and change the contract status based on contract start date and end date (i.e. change contract from Invoiced to active and from Active to expired).

One of customer’s CRM organization has this job running 10 PM at night and wanted to change this job on particular time (very early in the morning) to make sure contract status are up to date when users starts using CRM system.

There is job editor provided by MS to reschedule CRM system jobs but this does not include this specific job.

so following are steps we undertook with the help of CRM parter/MS support to reschedule this particular job in CRM system.

Step 1: run the following query to find the current Jobs in the relevant CRM organization. (note down the AsyncOperationid returned from this query as we will be using this in next step)

select AsyncOperationid,RecurrenceStartTime,postponeuntil,StatusCode, RecurrencePattern from AsyncOperation WHERE
Name = 'Update Contract States job'
StatusCode =10
and RecurrencePattern is not null

following quick details regarding important columns in this table.

RecurrencePattern is used to describe frequency and interval of the system jobs and please refer this article for more information on regarding this.

Postponeuntil is datetime field and indicate when this job will run next time. And it is UTC date meaning if this field contains “2012-10-23 09:08:00.000” and if your time zone is GMT + 1 then this job will run next time on “2012-10-23 10:08:00.000”

RecurrenceStartTime is also UTC datetime field which will be used to set next runtime of job, date part of this field is not important as long as it is set in the past.

Step 2: so using noted down AsyncOperationid in step 1 run following query to update recurrencestarttime, postponeuntil for this Update Contract States job .

update AsyncOperation set
RecurrenceStartTime = '2012-10-22 09:08:00.000',
postponeuntil = '2012-10-23 09:08:00.000'
WHERE AsyncOperationid = '5EB24ECB-60ED-4F59-801D-A6C19465C4D8'

So as per above update, this job will run at 9:08 AM (GMT time) in the morning every day.after job run if you verify the details then it would look as follows. So as you can see system will update postponeuntil (next run time) to next day (24th October) after this job run today (on 23th October).

****Important Notes regarding above change****
above change is unsupported so make sure you apply this change to Dev, Test environment before applying this to Live environment. Also make sure you take back up of database before doing this change.

Hope this helps..


4 thoughts on “CRM : Rescheduling the Update Contract States job

  1. maulikadhia

    I had cancelled this system job as it was pending for a long time. Post cancelling I did a cleanup of the asynctable using the SQL script to clean the cancelled & completed jobs.

    But this resulted in deletion of this job for permanent. Could you please help me get this job created in the system as this is no longer available in the system & contract creation isn’t possible until this job is available.

    Awaiting for your response.

    Maulik Adhia

  2. mayankp Post author

    Hi Maulik,

    what you need to do is add row in to your async table for this job type manuallly (using SQL Insert command), so if you got other environment (where this is still not cleared) or other organization database then in async table you will find this record.

    try to create similiar record in your organization async table for this.

    just be careful as this would be unsupported change so make sure relevant tables/DBs are back up before you do any changes..

    hope this helps..

    1. maulikadhia

      Hi Mayank,

      Thanks for the quick reply. I wanted to know there are 2 columns in asyncoperation table. Host ID & Cor-relation ID I am not able to understand which ID do they refer to.

      How do I generate them when I am making an entry of the system job from another instance of CRM?

  3. Johan Berghmans

    You could also perform the necessary changes by using the CRM API. By doing an update request on the AsyncOperation entity. For the available messages for the entity, see here:

    and for the fields and properties that are available, see here:

    The recurrencepattern is updateable for instance, as you can see.

    In this way you are performing supported changes to the system job in question.

    I’m going to try to implement a batch job based upon this. So I’ll need to test all of this first.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s