Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

Passing RunBaseBatch parm setter

(0) ShareShare
ReportReport
Posted on by 280

Hi all

 

Running AX 2012 R3 CU9.

 

Having a small issue with an SSRS print-to-file report I'm running in batch. In the following example, TEE_Register_SubmitToLangdons class extends RunBaseBatch.

 

TEE_Register_SubmitToLangdons.parmJournal() is a getter/setter method I've created in that class in order to filter the output to only the variable journal ID.

 

I've confirmed if I manually call parmJournal() in the run() method

of the class, it will filter as expected. However I need to be able to do it at runtime when the job is run, which would involve calling it on the job.

 

For some reason even though I call it (as shown bold below) the value passed seems to be a blank string.

 

static void TEE_Register_SubmitToLangdonsJob(Args _args, str _journal)

{

    BatchHeader batHeader;

    BatchInfo batInfo;

    TEE_Register_SubmitToLangdons rbbTask;

    str sParmCaption = "Submit to Langdon's " +

        date2str(today(),321,DateDay::Digits2,DateSeparator::Slash,DateMonth::Digits2,DateSeparator::Slash,DateYear::Digits4);

    ;

    rbbTask = new TEE_Register_SubmitToLangdons();

    _journal = "EXP-00009";

    rbbTask.parmJournal(_journal);

    info(rbbTask.parmJournal());

    batInfo = rbbTask .batchInfo();

    batInfo .parmCaption(sParmCaption);

    batInfo .parmGroupId(""); // The "Empty batch group".

    batHeader = BatchHeader ::construct();

    batHeader .addTask(rbbTask);

    batHeader .save();

    info(strFmt("'%1' batch has been scheduled.", sParmCaption));

}

 

How do I get this to pass correctly?

Any help would be much appreciated, thanks very much in advance.

Cheers

Luke

 

*This post is locked for comments

  • Martin Dráb Profile Picture
    Martin Dráb 231,305 Most Valuable Professional on at
    RE: Passing RunBaseBatch parm setter

    That's correct - the SysOperation framework does most of things for you. When you use RunBase, you always have to write a lot of boilerplate code, while with SysOperation, you need code only when you want to do something in special, such as when you don't like the automatically generated dialog. When everything is done for you and you don't think about how the magic happened, you may be even unaware of that you depend on such a framework.

  • lukbel Profile Picture
    lukbel 280 on at
    RE: Passing RunBaseBatch parm setter

    Hi Martin

    As far as I know I've never had to implement any code involving SysOperation? I understand the default reports interface with it, but I don't need to interfere with any of their workings beyond the content of them.

    The reason our company has been using RunBaseBatch was a few business requirements for running multiple reports in a loop. For these requirements, (currently) RunBaseBatch seems to handle the job fine. Again, this may change for us in the future if we ever upgrade and the class is removed, but I'm sure the same is the case for many of the built-in classes.

    At any rate, I realised while waiting on a CIL build - I was overthinking the problem. I no longer have the requirement to pass the journal ID from batch :) I'll mark this as answered.

  • Martin Dráb Profile Picture
    Martin Dráb 231,305 Most Valuable Professional on at
    RE: Passing RunBaseBatch parm setter

    Well, if you want to deal with just a single framework and SSRS report controllers are based on SysOperation framework, then adding RunBaseBatch to the solution goes against your own requirements.

    Note that if you want to run a report in a batch, you don't have to implement any batch by yourself. Because SSRS reports utilize SysOperation framework, they're already able to run in batch.

  • lukbel Profile Picture
    lukbel 280 on at
    RE: Passing RunBaseBatch parm setter

    Hi Martin

    Ah, thanks for the tip - I've tried implementing the version of pack/unpack from the tutorial as my changes so far have been consistent with what's inside it - however my batch job now seems to be in a loop :O I didn't see the response about dialog() implementations though so I will try that first

    As for not using SysOperation framework - we have a number of these reports and they all work fine and are well-documented. Our IT dept is small - I understand that SysOperation seems to have replaced it, but I would rather only have to troubleshoot one framework at a time if at all possible. If we end up moving to 365 in a few years and they've deprecated RunBaseBatch entirely, then we'll learn the new framework and convert all of our RunBaseBatch reports in one go :)

  • Martin Dráb Profile Picture
    Martin Dráb 231,305 Most Valuable Professional on at
    RE: Passing RunBaseBatch parm setter

    If you're building a new class, you should probably use the new framework instead of digging into the old one.

    Yes, unlike with SysOperation framework, you must implement the dialog by yourself. Add a field in dialog(); there you can set a value. Then override getFromDialog() and take the value from the dialog field and put it into parmJournalId. You don't normally need dialogPostRun().

    If you use SysOperation framework, simply create a data contract class with a single data member and use it as a parameter of your operation; the framework will generate UI, sets values to the dialog and gets values modified by users and also deals with (de)serialization (you don't need any macros or pack()/unpack()).

    Also note that SSRS reports already use SysOperation framework; it's not clear why you're not using what's already there.

  • Suggested answer
    nmaenpaa Profile Picture
    nmaenpaa 101,156 on at
    RE: Passing RunBaseBatch parm setter

    Usually you would like to have a dialog in RunBaseBatch implementations since that's used to set up the batch.

    If you don't want any own variables in the dialog, I guess you don't have to implement  / override the method.

  • lukbel Profile Picture
    lukbel 280 on at
    RE: Passing RunBaseBatch parm setter

    Hi Nikalaos,

    Ahh, I've now added to my class declaration:

    public class TEE_Register_SubmitToLangdons extends RunBaseBatch

    {

       TEE_RegisterJournalId parmJournalId;

       DialogField dlgparmJournalId;

       #define.CurrentVersion(1)

       #define.Version1(1)

       #localmacro.CurrentList

           parmJournalId

       #endmacro

    }

    Looking at where this is referenced in the tutorial class, do I need to implement a dialog(), getFromDialog() and dialogPostRun() method or are these inherited anyway? Where do I associate this dialog with my current parmJournalId declaration above?

  • Martin Dráb Profile Picture
    Martin Dráb 231,305 Most Valuable Professional on at
    RE: Passing RunBaseBatch parm setter

    One of the advantages of the newer framework (SysOperation) is that it handles serialization for you and you don't have to do it manually as in RunBase. A lot of people didn't know how to do it...

    Anyway, you can find some details in older discussions, such as pack() and unpack().

  • Suggested answer
    nmaenpaa Profile Picture
    nmaenpaa 101,156 on at
    RE: Passing RunBaseBatch parm setter

    Look at class Tutorial_RunbaseBatch and it's classDeclaration.

    Also, if you update the macro, you need to increment "CurrentVersion" or clear your usage data, or it doesn't work.

  • lukbel Profile Picture
    lukbel 280 on at
    RE: Passing RunBaseBatch parm setter

    Hi Nikolaos, thanks for your quick response

    Sorry, I've never worked with macros in the context of AX - could you pls specify or provide some documentation on this?

    Cheers

    Luke

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,494 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,305 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans