D365FO: batches and workflows not working after database restored in VM




Tired and worried of your batches malfunctioning/not working, after you have restored your database in your local VM? In case if you have faced this issue, just thought of sharing with you – this could save a good amount of your time.

  1. Going to your System admin à setup à Batch group, in case if you are unable to see this tab:


This tab is very much essential, as this makes you assign servers to your batch group. Skipping this tab, will essentially make your batch groups left unassigned to any batch server.

  1. A little inspection in the form’s INIT method said:







Which means if the ‘Batch priority based scheduling’ is enabled à then this tab won’t be shown.

  1. Go to features à and see this features is enabled:





 

Turn it off and come back to your Sys admin page à batch group à reload the page. This tab will be shown now:

 

 




Once you have selected the server, your batches should resume now. 

Now whoa, whoa, whoa -- your batches are still not running? You gotta check your event viewer.

There will be errors like this:

Object Server DynamicsAXBatchManagement:

[Microsoft][ODBC Driver 17 for SQL Server][SQL Server]Index "I_3368STATUSORIGSTARTDATETIMEIDX" on

table "BATCHJOB" (specified in the FROM clause) is disabled or resides in a filegroup which is not

online.

UPDATE T1 SET STATUS=?,STARTDATETIME=?,EMITBUSINESSEVENT=?,MODIFIEDDATETIME=?,RECVERSION=?,STARTDATETIMETZID=? FROM BATCHJOB T1 WITH ( INDEX(I_3368STATUSORIGSTARTDATETIMEIDX), FORCESEEK, READPAST, ROWLOCK, READCOMMITTEDLOCK) WHERE ((STATUS=?) AND (ORIGSTARTDATETIME<=?)) AND EXISTS (SELECT 'x' FROM BATCHJOBACTIVEPERIOD T2 WITH ( READPAST ROWLOCK READCOMMITTEDLOCK) WHERE ((T2.ID=T1.ACTIVEPERIOD) AND ((((T2.FROMTIMEUTC<=T2.TOTIMEUTC) AND (T2.FROMTIMEUTC<=?)) AND (T2.TOTIMEUTC>=?)) OR ((T2.FROMTIMEUTC>=T2.TOTIMEUTC) AND ((T2.FROMTIMEUTC<=?) OR (T2.TOTIMEUTC>=?))))) AND EXISTS (SELECT 'x' FROM BATCH T3 WITH ( READPAST ROWLOCK READCOMMITTEDLOCK) WHERE ((T3.BATCHJOBID=T1.RECID) AND (T3.GROUPID=?))))

session 2 (-AOS-)

 

 

Then you need to run the below queries:

ALTER INDEX [I_3368STATUSORIGSTARTDATETIMEIDX] ON [dbo].[BatchJob] REBUILD  WITH ( PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON, ONLINE = OFF, SORT_IN_TEMPDB = OFF )

GO

 

 

ALTER INDEX [I_22692FINISHINGIDX] ON [dbo].[BatchJobHistory] REBUILD  WITH ( PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON, ONLINE = OFF, SORT_IN_TEMPDB = OFF )

GO

 

These are required to enable the above mentioned keys from BatchJob and BatchJobHistory tables.

Now you would see your batches have resumed, your workflows have resumed working too.

Comments

Popular posts from this blog

X++ : mistakes which developers commit the most

Make your menu items visible on main menu, conditionally,, using this cool feature of D365FO

Speed up your execution performance by using SysGlobalCaches