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, ...
Suggested Answer

Batch job not running when batch processing is Yes.

(1) ShareShare
ReportReport
Posted on by
Hi Team,
 
I have a custom batch job which does not have any parameter. When this batch job is ran, it just Ends in 3 seconds and nothing happens. There are no logs on batch jobs.
 
When I debugged, I found that the service class is not called and it throws a exception directly. For this we have only created controller and service class only, as no parameters are required.



Above is the exception thrown.
Please help.
 
Thanks
I have the same question (0)
  • Martin Dráb Profile Picture
    239,140 Most Valuable Professional on at
    This code indeed can't run in batch. It refers to a form, but no form reference can be stored in the batch table. You'll need to redesign your solution. If you don't know how, please explain to us what you're trying to achieve with this code.
  • Suggested answer
    Waed Ayyad Profile Picture
    9,100 Super User 2026 Season 1 on at
    Hi,
     
    Check the following blog about creating batch job:
     
     
    Thanks,
    Waed Ayyad
    If this helped, please mark it as "Verified" for others facing the same issue
     
  • Karuna Dogra Profile Picture
    on at
    Hi Martin,
     
    The requirement is that, I have a custom form which has some transaction data. I have a button called Export to excel which exports that forms data to excel. However that export takes a lot of time and user has to wait until the processing ends. Sometime it result into timeout also.
    That's why we have added batch functionality on that button 'Export to excel' so when user clicks on it the Run in batch forms open and user can set the 'batch processing' as Yes and then it should run in batch.
    Please help.
  • Layan Jwei Profile Picture
    8,165 Super User 2026 Season 1 on at
    Hi,
     
    This might be a similar thread, check if it helps 
     
    Also can you please show us ur full code
     
    Thanks,
    Layan Jweihan
    Please mark this answer as "Verified" if it solved your issue. In order to help others who will face a similar issue in the future
  • Bharani Preetham Peraka Profile Picture
    3,634 Moderator on at
    Before answering your question I would like to see the code. 
     
    It seems when clicking export to Excel, either the args object or some class is not getting buffer but you are calling some method from it. So please share us the code at clicked method and the controller class.
  • Martin Dráb Profile Picture
    239,140 Most Valuable Professional on at
    Unfortunately, your description didn't tell me why and where you're calling the failing code.
     
    If your export logic exports just selected records and just fields visible on the form, then you need to pass this information to the batch through a contract class. Accessing the form from the batch server isn't possible.
  • Karuna Dogra Profile Picture
    on at
    Hi,
     
    This button "Export to excel" is actually a action menu item button and on that action menu item my controller class is selected as object.
    /// <summary>
    /// The Class used to export Global production order qty
    /// </summary>
    /// GlobalAllProdOrderQty
    public class xyzProductionOrderQtyController extends SysOperationServiceController
    {
    
        /// <summary>
        /// Method to show description of the class.
        /// </summary>
        /// <returns>Description</returns>
        public Description getCaption()
        {
            return "@KGlobalProductionOrdersQty";
        }
    
        /// <summary>
        /// method used to construct controller and data contract.
        /// </summary>
        /// <param name = "_args">args</param>
        /// <returns>controller object</returns>
        public static xyzProductionOrderQtyController construct(Args _args)
        {
            xyzProductionOrderQtyController controller;
    
            controller = new xyzProductionOrderQtyController (classStr(xyzProductionOrderQtyServices),
                                                            methodStr(xyzProductionOrderQtyServices),run),
                                                            SysOperationExecutionMode::Synchronous);
            controller.parmDialogCaption("@KProductionOrdersQty");
    
    
            return controller;
        }
    
        /// <summary>
        /// main
        /// </summary>
        /// <param name = "_args">args</param>
        public static void main(Args _args)
        {
            xyzProductionOrderQtyController controller = xyzProductionOrderQtyController (_args);
    
            controller.startOperation();
        }
    
    }
     
    And this will not work for selected records. All data which is there in this form/table should be exported to excel and get downloaded. The requirement is that when this button is clicked then entire data showing up on form should be downloaded in to excel and process should run in batch.
     
  • Martin Dráb Profile Picture
    239,140 Most Valuable Professional on at
    You still haven't told us anything about the problematic code, but I see you aren't calling it from the controller, therefore it must be in the service. Referring to the form from the batch server is impossible, therefore we now know that your code is guaranteed to fail.
     
    But until you give us at least some information about the relevant code, I can't comment on how you can redesign it.
  • Suggested answer
    Waed Ayyad Profile Picture
    9,100 Super User 2026 Season 1 on at
    Hi,
     
    Add the DataSource property to the menu item name, and check the below links about getting the selected records from caller form:
     
     
    Thanks,
    Waed Ayyad
    If this helped, please mark it as "Verified" for others facing the same issue
     
  • Martin Dráb Profile Picture
    239,140 Most Valuable Professional on at
    Setting the Data Source property is not a solution of the problem. The code trying to access the form from the build server will still keep failing. Also, Karuna isn't interested in selected records. And selected records wouldn't be passed to the batch anyway, because no contract class is in use.

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 689

#2
André Arnaud de Calavon Profile Picture

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

#3
Syed Haris Shah Profile Picture

Syed Haris Shah 258 Super User 2026 Season 1

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans