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 pass args from class to main method of class that extends runBaseBatch?

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

Hi , 

I have this dialog : 

pastedimage1600163955403v1.png              

public void run(Args _args)
{
    
    dialog.run();
        if (dialog.closedOk())
        {
            BatchClass::main(_args);
        }
}

When I click on button "Ok" I want to pass args in the 2end class that extends runBase Batch : 

When I click on button Ok , this form will be opening  : 

pastedimage1600164201691v2.png        

public static void main(Args _args)
{
    BatchClass    batchClass;
   
    batchClass = BatchClass::construct();
    batchClass.caption();
    if(batchClass.prompt())
   {
        RoleVersion = _args.record(); //When I run this code on batch the value of 
       // Role version was nul
        RoleVersion.run();
   }
 }

I don't understand why  args is null when I run this class in batch.

  • Suggested answer
    nmaenpaa Profile Picture
    nmaenpaa 101,156 on at
    RE: How to pass args from class to main method of class that extends runBaseBatch?

    About my recommendations - if you followed then, then you must have adjusted your code. So far we have never seen your full batch class code. It might be useful if you could share your code with us, allowing us to spot possible issues in it.

    You can set the "Execute business operations in CIL" in your user options -> Development tab.

    And actually this info can be found also by doing a web search for "dynamics ax 2012 execute business operations in CIL". I always recommend first asking from a web search engine, only then from other people :) This way you will get quicker results.

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: How to pass args from class to main method of class that extends runBaseBatch?

    Hi, 

    @Nikolaos Mäenpää , yes I  looked  at your recommendations  but always I have the same issue.

    @Martin Dráb  , I set the business operations in CIL = No   => but I get the same result

  • Martin Dráb Profile Picture
    Martin Dráb 231,329 Most Valuable Professional on at
    RE: How to pass args from class to main method of class that extends runBaseBatch?

    Try running main() on client and run() on server (with  Execute business operations in CIL = No). I suspect you'll already find a problem there and you won't have to either run or debug a batch. Even if you find that it works, it will be extremely valuable information (proving that serialization etc. works correctly).

    Then try it with Execute business operations in CIL = Yes. If it stops working, we'll know that your problem is related to CIL.

    Only if all these things work, it's time to test batch jobs.

  • nmaenpaa Profile Picture
    nmaenpaa 101,156 on at
    RE: How to pass args from class to main method of class that extends runBaseBatch?

    Hi Basma WED,

    You can install Visual Studio or ask someone to install it for you. This way you can debug the batch.

    Meanwhile, did you already have  a chance to look at my recommendations in my 2 previous messages?

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: How to pass args from class to main method of class that extends runBaseBatch?

    HI Martin , I havnt visual studio in my VM to debug the batch

  • Martin Dráb Profile Picture
    Martin Dráb 231,329 Most Valuable Professional on at
    RE: How to pass args from class to main method of class that extends runBaseBatch?

    Do you have any specific reason for not using the debugger and not following the steps of debugging I suggested in my reply?

    Debugger is the most powerful tool you have for debugging and ignoring it doesn't look wise to me.

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: How to pass args from class to main method of class that extends runBaseBatch?

    HI, 

    I add info in the method run like this :  

    public void run()
    {
          EUKSecurityRole eukSecurityRole;
          info(_roleNameGlb);   // packed value
          info(int642str(_matrixRoleVersion.RecId));
          eukSecurityRole = EUKSecurityRole::construct(_roleNameGlb, _matrixRoleVersion);
          }

    pastedimage1600262421640v1.png

  • Suggested answer
    nmaenpaa Profile Picture
    nmaenpaa 101,156 on at
    RE: How to pass args from class to main method of class that extends runBaseBatch?

    Ah, one more thing.

    When you use RunBaseBatch, please put all your business logic in the run method of the class (or call it from the run method).

    You can use class Tutorial_RunbaseBatch class as an example.

    Perhaps this explains your problem.

  • nmaenpaa Profile Picture
    nmaenpaa 101,156 on at
    RE: How to pass args from class to main method of class that extends runBaseBatch?

    Thanks for the clarification.

    And what values "are always null" in batch? Did you debug it? Can you show a screenshot where we see the values in the debugger? Or did you just determine that the values are null, based on the output of the batch? Please share all possible info with us so that we are in the same page and can help you as good as possible.

    Basically it should work the same way in batch and no-batch.

    One thing you can try is to clear your usage data and then run the batch again.

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: How to pass args from class to main method of class that extends runBaseBatch?

    I means by  "that is what I do in the main method of batch class, but the values always null" =>when I set up the batch 

    pastedimage1600248776999v1.png

    in the other case  :  

    pastedimage1600248830607v2.png

    the code  was executed without problem

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

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Vahid Ghafarpour – Community Spotlight

We are excited to recognize Vahid Ghafarpour as our February 2025 Community…

Tip: Become a User Group leader!

Join the ranks of valued community UG leaders

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 292,516 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,329 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans