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, ...
Answered

Add batch job execution to form dialog

(1) ShareShare
ReportReport
Posted on by 678

Hi All,

I would like to add a batch job function to a form dialog which is not a standard form dialog.

I have changed the class signature like 'Class A extends RunBaseBatch' from 'Class A extends RunBase'. as all jobs that must be able to run in a batch must inherit from this class.

What methods should I add to be able to execute batch job? also recurrence is not needed as it will use instant batch execusion. 

Thank you. 

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

    Hi ShawnDEV,

    there's a tutorial for you, called Tutorial_RunBaseBatch. You will find it in AOT.

  • ShawnDEV Profile Picture
    678 on at

    Hi Okay. I will try to follow it.

    However, I have an error after changing the signature to Class A extends RunBaseBatch.

    "A tab control is missing from the form."

    Why do I get this error?

    Thank you.

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

    Hi ShawnDEV,

    as you can imagine, it's not so easy to tell, based on the information that you shared. The issue must be in your code. And we can't see your code.

    Please go through the tutorial, and if you have some difficulties understanding it, just let us know.

  • ShawnDEV Profile Picture
    678 on at

    Hi,

    I tried to add methods: pack()

        public container pack()
        {
            return [#CurrentVersion,#CurrentList];
        }

    But I got an error that 'Instance of type 'Set' cannot be added to a container'

    This is because the variable within #localmacro.CurrentList macro is type of Set 

        Set                     selectedRecords = new Set(Types::Record);

    Is there a way to bypass it..? or do I need to change the data type totally?

    Thank you.

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

    You can only save primitive data types in the packed variables.

    You can store a container of RecIds, for example.

  • Verified answer
    Martin Dráb Profile Picture
    237,965 Most Valuable Professional on at

    You're wrong in thinking that batch classes must extend RunBaseBatch. That's true just for the older framework, but not for SysOperation framework.

    Using the newer framework will likely make it easier for you, because you don't have to implement serialization by yourself. You don't know how to do it anyway, so why don't let the system to do the hard work for you? You just need to add a List variable to a data contract, add a parm method and decorate it with a few attributes.

    If you insist on using RunBase framework, you'll need to learn a bit about serialization. Your code is failing because object references can't be stored in database - you would have to serialize the Set object in pack() and deserialize it in unpack(). It's not too difficult, but by recommendation is not doing it at all and using the SysOperation framework instead.

  • ShawnDEV Profile Picture
    678 on at

    Hi,

    I debugged it and got an error 'A tab control is missing from the ... form' in the following class DialogForm.buildControl method.

        FormBuildControl buildControl(FormControlName name)
        {
            Object ctrl = design.control(name);
    
            if (! ctrl)
                throw error(strfmt("@SYS71925",this.form().name(),name));
    
            return ctrl;
        }

    should the form dialog pattern be 'Tab' in order to show the batch tab? 

    Thank you. 

  • nmaenpaa Profile Picture
    101,162 Moderator on at

    This doesn't seem to be related to batches at all.

    Since you share only fragments of information (and your code), it's really hard to help.

    Are you still using RunBaseBatch framework? What is this "buildControl" method? Is it in your batch class? Why?

  • ShawnDEV Profile Picture
    678 on at

    Hi,

    No, it is from standard DialogForm.buildControl method.

    My batch class contains the following dialog() method and its' pattern is Dialog-basic.

    public Object dialog()
        {
            DialogRunbase dialog = Dialog::newFormnameRunbase(formStr(MyDialogForm),this);
    
            dialog.caption(MyDialogCaption);
            dialog = this.dialogInternal(dialog);
    
            return dialog;
        }

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

    Normally you don't have any forms in batch dialogs.

    Based on the information that I know (which is next to nothing, but all that you shared), my advice is: don't try to use forms in batch dialogs. Just implement the dialog in x++.

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 451 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

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

#3
BillurSamdancioglu Profile Picture

BillurSamdancioglu 239 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans