Code to Schedule a batch job after every 1 hour

 Code:


// Create a new instance of the SysOperationServiceController class

SysOperationServiceController batchJobController = new SysOperationServiceController();


// Set the main class for the batch job

batchJobController.parmMainClass(classnum(MyBatchJobClass));  //Replace "MyBatchJobClass" with the name of the X++ class that contains the batch job code.


// Set the batch job name

batchJobController.parmBatchJobName("My Batch Job"); // Give some batch job name


// Set the recurrence pattern for the batch job to run every hour

batchJobController.parmRecurrencePattern("Hourly"); // set the time

batchJobController.parmHourInterval(1); // it executes after every 1 hour


// Run the batch job

batchJobController.run();


The code above creates an instance of the SysOperationServiceController class and sets the main class, batch job name, and recurrence pattern for the batch job. Finally, the code calls the run method on the batchJobController object to run the batch job.

Note: The run method is synchronous, which means that the method call will not return until the batch job has completed. If you want to run the batch job asynchronously, you can use the runAsync method instead.


Comments

Popular posts from this blog

How to Create a wizard in x++ d365

how to post trade agreement journals automatically using x++ code

X++ code to CREATE AND POST A TRADE AGREEMENT IN MICROSOFT DYNAMICS 365 in D365 F & O