Skip to main content

Notifications

Announcements

No record found.

Dynamics 365 Community / Forums / Finance forum / RunBaseBatch Class DYN...
Finance forum
Suggested answer

RunBaseBatch Class DYN365FO not running on background

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!

  • nmaenpaa Profile Picture
    nmaenpaa 101,148 on at
    RE: RunBaseBatch Class DYN365FO not running on background

    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! 

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: RunBaseBatch Class DYN365FO not running on background

    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.

  • Suggested answer
    Emilio Molina Profile Picture
    Emilio Molina 105 on at
    RE: RunBaseBatch Class DYN365FO not running on background

    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!

  • Martin Dráb Profile Picture
    Martin Dráb 225,783 Super User on at
    RE: RunBaseBatch Class DYN365FO not running on background

    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.

  • Emilio Molina Profile Picture
    Emilio Molina 105 on at
    RE: RunBaseBatch Class DYN365FO not running on background

    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.

  • Emilio Molina Profile Picture
    Emilio Molina 105 on at
    RE: RunBaseBatch Class DYN365FO not running on background

    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();

       }

    }

  • Martin Dráb Profile Picture
    Martin Dráb 225,783 Super User on at
    RE: RunBaseBatch Class DYN365FO not running on background

    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.

  • Suggested answer
    Sukrut Parab Profile Picture
    Sukrut Parab 71,643 Moderator on at
    RE: RunBaseBatch Class DYN365FO not running on background

    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]

Helpful resources

Quick Links

Replay now available! Dynamics 365 Community Call (CRM Edition)

Catch up on the first D365 Community Call held on 7/10

Community Spotlight of the Month

Kudos to Saurav Dhyani!

Congratulations to the June Top 10 community leaders!

These stars go above and beyond . . .

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 288,459 Super User

#2
Martin Dráb Profile Picture

Martin Dráb 225,783 Super User

#3
nmaenpaa Profile Picture

nmaenpaa 101,148

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans