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 :
Dynamics 365 Community / Forums / Finance forum / RunBaseBatch Class DYN...
Finance forum

RunBaseBatch Class DYN365FO not running on background

(0) ShareShare
ReportReport
Posted on by 105

I am trying to implement a RunBaseBatch Class on Dynamics 365 FO. I have found documentation on how to implement this for AX2012, I followed all steps and compiles but when running an clicking the menu option, it displays the run on background options on form, but when selecting run on background switch the execution does not goes to background. I have debugged the code, and everything seems to be fine... no errors, and the final method does run but as I said it does not run on background.

I found this issue discussed on an AX2012 thread and everything seems to point to change the “run on” property of the class to "CalledFrom" which is the default and also does not seem to be able to change. And the Run on property of the Menu Item Action button property to "Server", the thing is that the button does not has a "Run on" property.

Can anyone help me or point me to a DYN365 documentation on this?

Thanks in advance!

  • Suggested answer
    Sukrut Parab Profile Picture
    71,741 Moderator on at

    When you say its not running in the background , it means you are not able to add it in the batch from UI ? Do you have canGoBatch method overridden ?

    You should try to implement sysoperation framework instead of using runbaseBatch. You can take a look at this whitepaper to understand it .

    [View:http://axlogics.blogspot.com/2017/12/sysoperation-framework-in-dynamics-365.html:750:50]

  • Martin Dráb Profile Picture
    240,744 Most Valuable Professional on at

    What code do you have in main() method? Maybe you haven't implemented it correctly.

    Your statement "the final method does run but [...] it does not run on background" suggest that run() gets executed immediately, so not "everything is fine". All what should happen at that time is putting a record to the batch table, not executing the actual business logic.

    By the way, RunOn property doesn't have any meaning in D365FO, because all X++ code is executed on server. There is no client application executing X++ anymore.

  • Emilio Molina Profile Picture
    105 on at

    This is my main method code. How do you implemented it correctly? Can you point me to documentation on how  or tell me what is wrong with this? What is the difference with the "sysoperation framework" as mentioned by Sukrut Parab.

    thanks for your help!

    public static server void main(Args args)

    {

       if(args)

           {

               FormRun Sender  = args.caller();

               FormDataSource projtableform_ds = sender.dataSource('ProjTable');

               ProjTable projtableform = projtableform_ds.cursor();

                _ProjId = projtableform.ProjId;        

           }

       ISProjGeneraCampanaBatch               ISProjGeneraCampanaBatch;

       ISProjGeneraCampanaBatch     = new ISProjGeneraCampanaBatch();

       if (ISProjGeneraCampanaBatch.prompt())

       {

           //ISProjGeneraCampanaBatch.run();

           ISProjGeneraCampanaBatch.runOperation();

       }

    }

  • Emilio Molina Profile Picture
    105 on at

    Thanks for your reply. Yes I do have a CaGoBatch method returning true.  And yes i am trying to add it from UI.

    Thanks for your recommendation. I will review it.

  • Martin Dráb Profile Picture
    240,744 Most Valuable Professional on at

    If you use RunBaseBatch and set up batch processing, prompt() should call doBatch() (to schedule the batch) and return false. If prompt() returns true and run() / runOperation() gets called, debug the failing condition in prompt() to see where things went wrong.

    Regarding SysOperation framework, look at SysOperation Framework Overview and whitepapers mentioned there.

  • Suggested answer
    Emilio Molina Profile Picture
    105 on at

    Thanks a lot for your help Martin.  I ended up copying the code from SysOpSampleBasicRunbaseBatch found in AOT. If this helps anyone struggling with this.

    I do find this to be very sensitive, as just adding a couple of lines to the run method seem to break the code and did not report any error in the job, it goes batch not does not seems to be executing the code.  I finish copying the same lines to a class outside the RunBaseBatch class, calling this new class from the run method and everything starts working again. Do not understand why! It will be nice to have some documentation of how this works and do to understand what cause this “estrange” behavior!

  • Community Member Profile Picture
    on at

    i still can't see how you fixed this issue.

    I experience the same - runBaseBatch job works fine in client/interactive mode, but doesn't in batch mode.

    Seams like in Batch mode same query returns now values.

  • nmaenpaa Profile Picture
    101,172 Moderator on at

    You should go through your code to spot any issues. If you would like us to help, could you please share your code with us? It's not possible to tell what could be wrong, based on the information that you have shared with us.

    Thanks! 

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

November Spotlight Star - Khushbu Rajvi

Congratulations to a top community star!

Forum Structure Changes Coming on 11/8!

In our never-ending quest to help the Dynamics 365 Community members get answers faster …

Dynamics 365 Community Platform update – Oct 28

Welcome to the next edition of the Community Platform Update. This is a status …

Leaderboard > Finance

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans