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

Method Runbase.canRunInNewSession must be overridden

(0) ShareShare
ReportReport
Posted on by 1,552

Hi,

so at first i got a warning to use runOperation instead of Run

BP Rule: [BPUpgradeCodeRunBaseRunCalled]:
Methods should call the test.runOperation()method instead of the test.run() 
method on Runbase derived classes.Change the code from calling run to call runOperation.	

when i switched to .RunOperation, i got the warning specified in the question (Method Runbase.canRunInNewSession must be overridden)

How to fix it?

I have the same question (0)
  • Suggested answer
    Gunjan Bhattachayya Profile Picture
    35,423 on at

    Hi junior AX,

    You can override canRunInNewSession method and return false. You can check the class AssetBudgetUpdate_Journal as an example.

    protected boolean canRunInNewSession()
    {
        return false;
    }

  • WillWU Profile Picture
    22,361 on at

    Hi junior AX,

    Please check this blog. Just override the canRunInNewSession method in your batch class.

    rahulmsdax.blogspot.com/.../create-runbase-batch-class-in-d365-f-x.html

  • junior AX Profile Picture
    1,552 on at

    Hi Gunjan and Will Wu

    The class is not Mine. So if i override the method to false. Would that affect the class? ( the class didn't use this method so i guess it's set to true be default)
    this method is used in form, so i wanted to call the logic from another class internally

    and what does this method run in new session means?

  • Gunjan Bhattachayya Profile Picture
    35,423 on at

    Hi junior AX,

    How is the method used on a form? Please check this thread for a detailed explanation regarding this method.

  • junior AX Profile Picture
    1,552 on at

    Hi Gunjan,

    I mean there is a button on the form that calls a class as shown below

        static void  main(Args _args)
        {
            AAClass    class;
            ;
            if (!_args || (_args && !_args.record()))
            {
                  // logic
            }
        
            class = AAClass::construct();
            class.getLast();
            class.initFromArgs(_args);
        
            if (class.prompt())
            {
                class.run();
                class.refreshDataSource();
            }
        }

    so what i need to do is that i need to call the logic of this button in another class. so here's what i did:

        public void AAMethod(AATable2 _table2)
        {
            AATable1 table1;
            while select table1 where table1.Id == _table2.Id
            {
                if( !table1.Id1)
                {
                    Args args = new Args();
                    args.record(table1);
                    AAClass class  = AAClass::construct();
                    class.getLast();
                    class.initFromArgs(args);
        
                    if (class.prompt())
                    {
                        class.run();
                    }
                }
            }
        }

    so my question is:

    1. if I override canRunInNewSession to false, would that affect the actual button logic?

    2. what does canRunInNewSession do?

    3. what does if prompt() in the code mean? 

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

    1. No

    2. I'm not 100% sure, but based on the name, and the comments above that method in RunBase class, it controls whether the class can run in a new session (=asynchronously, instead of your current user session) when you don't run it in batch. You can play around with it and try

    3. prompt() method prints the dialog. If user clicks OK on the dialog, the method returns true. Otherwise it returns false and you should not run your logic.

  • junior AX Profile Picture
    1,552 on at

    Hi Nikolaos.

    since i'm not using the button on the form and i copied the logic to call it by code. Then i don't need to add if class.prompt() right? i should call the run method directly right?

    if (class.prompt())
    {
        class.run();
    }

    but how come when i call it by code it enters class.run even though no dialog appears and i don't click ok?

  • nmaenpaa Profile Picture
    101,160 Moderator on at

    Could be. Since we haven't seen any code from that actual class, we can't know.

    Also, I suggest you to debug it to find more answers. Please share your learnings with us. Thanks!

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

#2
André Arnaud de Calavon Profile Picture

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

#3
Sohaib Cheema Profile Picture

Sohaib Cheema 307 User Group Leader

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans