Last week I embarked on a series of posts on DB restore scripts for Dynamics AX by creating a list of items in your AX database that need to be updated/reconfigured when restoring a database from a production environment to a development or QA one.
This post is closely tied to and relies on my previous post on re-configuring your AOS and Batch AOS instances to work, so ensure you have completed that script before continuing. Today I will be looking at re-configuring your actual batch jobs and batch groups to function correctly under your new environment.
In the Dynamics AX 2012 client the configurations that we are going to look at are:
1. Batch Groups, accessed via System Administration -> Setup -> Batch Groups
Depending on the configuration of your source system (e.g. Production) you may have multiple AOSs setup as batch servers whereas your DEV and QA would most likely just have a single AOS that functions as the batch AOS. You may also have a number of batch jobs that that you explicitly don’t want to run in a development environment, such as integrations to vendors, automatic ordering etc… Therefore our scripts will need to do the following:
1. For each of our batch groups we want to:
– Delete all but one of their selected/linked “batch servers”
– Re-point the remaining link to the current batch server setup in our previous script.
2. Disable batch jobs that we do not want to run in our development environment.
Before proceeding, please note, these scripts are intended as guidelines and do make various assumptions on the state of your environment. For example I’m assuming that your batch jobs were cleanly shutdown with their status’ either in “Error, ended, or waiting” (not Cancelling or Executing). Please adjust these scripts to suit your environment.
The following SQL code will accomplish the above. I have parameterised the SQL for easier reuse or adjustment.
--Reuse the parameter declared for the SSRS and AOS update script Declare @AOS varchar(30) = '[AOSID]' -- Must be in the format '01@SEVERNAME' -- #1.1 Clear out but one link between each batch server group and batch server. delete from BATCHSERVERGROUP where RecId not in (select min(recId) from BATCHSERVERGROUP group by GROUPID) -- #1.2 Repoint remaining links to the active aos/batch server. update BATCHSERVERGROUP set SERVERID=@AOS where serverid != @AOS -- Optional to see "affected row count" -- #2 - Disable batch jobs that should not run in a production environment. Copy the two lines below for each batch job you want to disable. update batchjob set batchjob.status=4 where batchjob.CAPTION = '[BATCHJOBNAME]' update batch set batch.STATUS=4 from batch inner join BATCHJOB on BATCHJOBID=BATCHJOB.RECID AND batchjob.CAPTION = '[BATCHJOBNAME]'
I hope this assists you and will be useful in your management of your AX environments.