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

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Suggested Answer

How to run batch job Using sysoperation framework?

(0) ShareShare
ReportReport
Posted on by 932

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

I have the same question (0)
  • nmaenpaa Profile Picture
    101,160 Moderator on at

    Could you start by sharing your code? I'm sure it would help us understand what is wrong with it.

    Thanks!

  • nmaenpaa Profile Picture
    101,160 Moderator on at

    Also, I'm sure you already checked the official documentation and whitepaper, but just in case you didn't please do it: docs.microsoft.com/.../sysoperation-framework-overview

  • Gunjan Bhattachayya Profile Picture
    35,423 on at

    Hi Basma,

    Could you please share your code?

  • Suggested answer
    vinitgoyal2005 Profile Picture
    6,332 on at

    Hi BASMA,

    If you have already implemented code using sys operations framework then Batch Tab will automatically and you need to go to the batch tab and set batch processing to yes. If you would like to see the sample of Sys operations framework then check www.artofcreation.be/.../

  • BASMA Profile Picture
    932 on at

    public static void main(Args _args)
    {
        EUK_AddBatchJobToRoleController     addBatchJobToRoleController;
        EUKMatrixRoleCreateRole             eukMatrixRoleCreateRole;
        EUK_AddBatchJobToRoleContract       addBatchJobToRoleContract;
        str CompanyId;
        Args                               argsGenerationFromMatrix;
    
        Description                     description;
        EUKMatrixNum                    matrixID;
        EUKMatrixName                   matrixName;
        EUKVersionNum                   numVersion;
        Str130                          roleName;
        EUKSecurityRole                 eukSecurityRole;
        eukMatrixRoleVersion            eukMatrixRoleVersion;
        EUKHistoric                     historic;
        EUKMatrixRole                   eukMatrixRole;
        utcDateTime                     dateTime;
        FormRun                             callerForm;
        EUKRole                             eukRole;
        ;
        dateTime = DateTimeUtil::utcNow();
        // create a new instance of the controller
        addBatchJobToRoleController = new EUK_AddBatchJobToRoleController();
    
        // initialize from args
        // one of the things this will do is read the "parameters" property from the menu item
        addBatchJobToRoleController.initializeFromArgs(_args);
        CompanyId = CompanyInfo::Find().DataArea;
        argsGenerationFromMatrix = new Args();
        argsGenerationFromMatrix.name(formstr(EUKMatrixRoleGenerationFromMatrix));
        if(_args.caller() && _args.record() && _args.record().TableId == tableNum(EUKMatrixRoleVersion))
        {
    
            callerForm  = _args.caller();
            eukMatrixRoleVersion = _args.record();
            eukMatrixRoleCreateRole = EUKMatrixRoleCreateRole::constructFromArgs(_args);
    
            eukMatrixRole = eukMatrixRoleCreateRole.eukMatrixRole();
            select firstonly eukRole where eukRole.RelatedMatrix == eukMatrixRole.MatrixID;
            addBatchJobToRoleContract   = addBatchJobToRoleController.getDataContractObject('_addBatchJobToRoleContract');
            matrixID   = addBatchJobToRoleContract.parmMatrixNum(eukMatrixRole.MatrixID);
            matrixName = addBatchJobToRoleContract.parmMatrixName(eukMatrixRole.MatrixName);
            numVersion = addBatchJobToRoleContract.parmVersionNum(eukMatrixRoleVersion.VersionNumber);
            if(eukRole)
            {
                roleName = addBatchJobToRoleContract.parmRoleName(eukRole.Name);
                description=addBatchJobToRoleContract.parmDescription(strFmt("@EUK269", addBatchJobToRoleContract.parmRoleName(eukRole.Name)));
    
            }
            else
            {
                roleName = addBatchJobToRoleContract.parmRoleName(CompanyId "-" addBatchJobToRoleContract.parmMatrixName(eukMatrixRole.MatrixName));
                description=addBatchJobToRoleContract.parmDescription(strFmt("@EUK272",roleName));
            }
            addBatchJobToRoleController.startOperation();
            
            if(eukRole)
            {
                
                 eukSecurityRole = EUKSecurityRole::construct(roleName, eukMatrixRoleVersion);
                 eukSecurityRole.cleanRole();
                 eukSecurityRole.updateRole(eukMatrixRoleVersion);
    
                 info("@EUK270");
                 historic.fillHistoric(EUKTypeAction::MAJRole,description,curUserId(),dateTime,EUKMatrixRole.MatrixID);
                 new MenuFunction(menuitemDisplayStr(EUKMatrixRoleGenerationFromMatrix),MenuItemType::Display).run();
            }
           else
            {
                
                eukSecurityRole = EUKSecurityRole::construct(roleName, eukMatrixRoleVersion);
                eukSecurityRole.createRole(eukMatrixRoleVersion);
                eukSecurityRole.updateRole(eukMatrixRoleVersion);
    
                 info("@EUK273");
                 historic.fillHistoric(EUKTypeAction::GenerationRole,description,curUserId(),dateTime,EUKMatrixRole.MatrixID);
                 new MenuFunction(menuitemDisplayStr(EUKMatrixRoleGenerationFromMatrix),MenuItemType::Display).run();
                 if(callerForm && (callerForm.name() == formStr(EUKMatrixRoleVersion)) && formHasMethod(callerForm,identifierStr(updateDesign)))
                 {
                        _args.caller().updateDesign();
                         EUKMatrixRole::updateCallers(callerForm,_args,eukMatrixRoleVersion);
                 }
            }
            
        }
    }

    The code after the instruction start() operation , i want to execute it in batch n how can I do that? 

    Thanks

  • BASMA Profile Picture
    932 on at

    this the class Controller , Also I create 2 other class : 

    EUK_AddBatchJobToRoleContract

    pastedimage1599648002486v1.png

  • Suggested answer
    nmaenpaa Profile Picture
    101,160 Moderator on at

    Seems you shared only part of your code - only one method.

    Anyway, when you work with SysOperation or RunBaseBatch you should not put your business logic in the main method of the controller class. Main method is executed when user clicks the menu item.

    But you want your code to be executed when the actual batch task runs.

    Please check the documentation and whitepaper regarding SysOperation, which I mentioned in my previous message.

  • BASMA Profile Picture
    932 on at

    So , I should put the code after startOperation in the run() method

    But I have one issue , how cnaI use global variable in static method

    I need some variable from method main , to use it in the run method ??

  • Suggested answer
    Gunjan Bhattachayya Profile Picture
    35,423 on at

    Hi Basma,

    You can follow this example as well. 

    From your method it looks like you are trying to run this process clicking on a button from another form. You are also trying to open a form using 

    new MenuFunction(menuitemDisplayStr(EUKMatrixRoleGenerationFromMatrix),MenuItemType::Display).run();

    I don't think you can perform this using a batch process. 

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

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

#1
Martin Dráb Profile Picture

Martin Dráb 646 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 529 Super User 2025 Season 2

#3
Sohaib Cheema Profile Picture

Sohaib Cheema 285 User Group Leader

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans