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 :
Microsoft Dynamics AX (Archived)

Passing RunBaseBatch parm setter

(0) ShareShare
ReportReport
Posted on by 282

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

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

    You need to add the variable in CurrentList macro in the class declaration of your RunBaseBatch class.

  • lukbel Profile Picture
    282 on at

    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

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

    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.

  • Martin Dráb Profile Picture
    237,967 Most Valuable Professional on at

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

  • lukbel Profile Picture
    282 on at

    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?

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

    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.

  • Martin Dráb Profile Picture
    237,967 Most Valuable Professional on at

    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.

  • lukbel Profile Picture
    282 on at

    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
    237,967 Most Valuable Professional on at

    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
    282 on at

    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.

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 > 🔒一 Microsoft Dynamics AX (Archived)

#1
Martin Dráb Profile Picture

Martin Dráb 4 Most Valuable Professional

#1
Priya_K Profile Picture

Priya_K 4

#3
MyDynamicsNAV Profile Picture

MyDynamicsNAV 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans