web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Answered

How to perform a task in batch job on click of form OK button?

(1) ShareShare
ReportReport
Posted on by 162
Hi ,
I am trying to perform a task in batch job which should be done when I click ok button of ax form. I have called the main method from the click method of button, but when I check the batch jobs in UI, I cannot see my batch job. 
public void clicked(){     super();      BasisController ::main(); }
Controller class 
 
 class BasisController extends SysOperationServiceController {        protected void new ()     {         super();         this.parmClassName(classStr(BasisService));         this.parmMethodName(methodStr(BasisService,processOperation));         this.parmDialogCaption(/cleanup/);         this.parmExecutionMode(SysOperationExecutionMode::Asynchronous);      }          public static void main ()     {         BasisController controller;          controller = new BasisController();         controller.showBatchTab(true);         controller.parmShowDialog(true);        controller.parmDialogCaption(/Cleanup/);                controller.startOperation();          }}
Service Class
 
class BasisService extends SysOperationServiceBase{    public void processOperation()    {        info(strFmt(/Hello/));    }}
 
Please let me know what am I doing wrong and how can I achieve the desired goal?
 
Please note : I tried 3 times for my code to look good, but everytime after updating the result, it looks same.Apologies for the same.
I have the same question (0)
  • Verified answer
    Martin Dráb Profile Picture
    239,118 Most Valuable Professional on at
    The obvious problem is that you aren't using a batch execution mode. Use SysOperationExecutionMode::ScheduledBatch or SysOperationExecutionMode::ReliableAsynchronous instead of SysOperationExecutionMode::Asynchronous.
     
    By the way, you should use an action menu item button instead of creating a clicked() method and calling main() from there. It just requires main() method be implemented correctly - you're missing Args parameter there. It simplifies security configuration and it allows reusability of the menu item and its setup (such as the label).
  • Harshal Jain Profile Picture
    162 on at
    Hi Martin,
    I am using this code in controller class in new method. But it did not work
     this.parmExecutionMode(SysOperationExecutionMode::Asynchronous);
     
  • Martin Dráb Profile Picture
    239,118 Most Valuable Professional on at
    Yes, I see you're using it and I'm telling you that SysOperationExecutionMode::Asynchronous doesn't run as a batch. If you want a batch, you mustn't use Asynchronous mode.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the March Top 10 Community Leaders

These are the community rock stars!

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
Giorgio Bonacorsi Profile Picture

Giorgio Bonacorsi 733

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 461 Super User 2026 Season 1

#3
Syed Haris Shah Profile Picture

Syed Haris Shah 278 Super User 2026 Season 1

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans