Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics AX forum
Suggested answer

How to run batch job Using sysoperation framework?

Posted on by 920

Hi, 

I create this dialog using SysOperation : 

pastedimage1599646598293v1.png

I want to choose in the second tabPag the recurrence of batch , But in which method of class I put my code : 

Now to put all code in the method main () , so  :  despite I chose the batch, the code is executed directly without going through the batch

  • Suggested answer
    nmaenpaa Profile Picture
    nmaenpaa 101,148 on at
    RE: How to run batch job Using sysoperation framework?

    This blog shows how to pass values from caller -> controller -> data  contract -> service class:

    community.dynamics.com/.../ax2012-sysoperation-part-2-sysoperationservicecontroller

  • BASMA Profile Picture
    BASMA 920 on at
    RE: How to run batch job Using sysoperation framework?

    Thanks Nikolaos Mäenpää  I understand the logic ,

    just one thing I need args from the main method , to use it in the batch => I means that I need It in the class service : 

    this is the method in service class , now just I display values 

    [SysEntryPointAttribute]
    public void CreateRole(EUKGnerateRoleContract _eukGnerateRoleContract)
    {
        // info the name parameter
        info(_eukGnerateRoleContract.parmDescription());
        info(_eukGnerateRoleContract.parmMatrixName());
        info(_eukGnerateRoleContract.parmMatrixNum());
        info(_eukGnerateRoleContract.parmRoleName());
        }

    pastedimage1599734409136v1.png

    I want to use args from controller in service class

  • Suggested answer
    nmaenpaa Profile Picture
    nmaenpaa 101,148 on at
    RE: How to run batch job Using sysoperation framework?

    Yes there is, in TutorialSysOperationService\runService. There it prints infolog "Done" when the batch is executed.

    And in TutorialSysOperationController\new we have code that points in the service class and runService method.

  • BASMA Profile Picture
    BASMA 920 on at
    RE: How to run batch job Using sysoperation framework?

    in the example, there isn't any business logic to execute in batch

  • Suggested answer
    nmaenpaa Profile Picture
    nmaenpaa 101,148 on at
    RE: How to run batch job Using sysoperation framework?

    new() method is not calling any business logic. There you merely tell which service class and method should be triggered when the batch runs.

    You can see all this in the simple example in the blog that I shared.

  • BASMA Profile Picture
    BASMA 920 on at
    RE: How to run batch job Using sysoperation framework?

    But the new method, is called before the startOperation method, so the code will execute directly.

    I am sorry for all these questions 

  • Suggested answer
    nmaenpaa Profile Picture
    nmaenpaa 101,148 on at
    RE: How to run batch job Using sysoperation framework?

    In the example blog, it's in the runService method of the service class.

    The method name can be anything, but in the new() method of your controller class you must tell the system which class/method to use when running the batch.

  • BASMA Profile Picture
    BASMA 920 on at
    RE: How to run batch job Using sysoperation framework?

    the problem is , where I can put the code of business logic  : that will be executed in batch.

    controller .startoperation() : opens  a setup dialog

  • Suggested answer
    nmaenpaa Profile Picture
    nmaenpaa 101,148 on at
    RE: How to run batch job Using sysoperation framework?

    I don't understand the question.

    When you run the code (main method of the controller class) it opens a setup dialog. There you can specify that you want to run it in batch. After you click OK, the job is saved in batch jobs. And then the batch processing will execute it.

  • BASMA Profile Picture
    BASMA 920 on at
    RE: How to run batch job Using sysoperation framework?

    I have the same instruction of code,

    now I want to execute the code in batch , where I can put it to run  in batch

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... 287,696 Super User

#2
Martin Dráb Profile Picture

Martin Dráb 225,490 Super User

#3
nmaenpaa Profile Picture

nmaenpaa 101,148

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans