web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Suggested answer

check sysoperation controller class execution context

(1) ShareShare
ReportReport
Posted on by 893
Hello,
 
I have a controller class and I need to check that it is being executed in batch. there is a method for this controller.isInBatch(). Also I need to check whether the session is interactive. I have found global method hasGUI() for this. I'd like to check this on the static method of my custom table and since controller. controller.isInBatch cannot be called on the static method my table, I don't want to pass it as parameter from the controller class to my custom table. On the other hand, I see that inside hasGUI() there is such code
 
 public static boolean hasGUI()
 {
     return xGlobal::hasClient() && !isRunningOnBatch() && !isRunningSyncEngine();
 }
maybe !isRunningOnBatch() is sufficient to check and I don;t need to pass controller.isInBatch() to the table method from my controller class?
I have the same question (0)
  • Martin Dráb Profile Picture
    235,800 Most Valuable Professional on at
    check sysoperation controller class execution context
    Why do you need to check whether it's in a batch or not? And what if it's processed asynchronously but not in a batch?
  • dark_knight Profile Picture
    893 on at
    check sysoperation controller class execution context
    From the controller I need to call a static method of my custom table. And inside that static method I need to check whether the execution context is in batch or not and also check whether the session is interactive or not. That's why I call hasGUI() on the static method. Inside hasGUI() I have the check already !isRunningOnBatch(). Is it enough? on the controller class there is method
    controller.isInBatch()
    I can pass the result of it to my customtable::staticmethod() but I don't find it elegant. therefore if calling !isRunningOnBatch() inside hasGUI() is enough then it would be great and I can not to pass controller.isinbatch() to my customtable::staticmethod(). Hope, it's understandable. 
  • Martin Dráb Profile Picture
    235,800 Most Valuable Professional on at
    check sysoperation controller class execution context
    Can you tell us more about the business scenario, please? It's not clear what you're trying to achieve.
    You said you wanted to check whether a controller runs in a batch, so why do you want involve a table? You don't need a table to say whether the controller runs inside a batch or not. Also, maybe you don't need to know it at all; the framework already has some logic using different behaviour inside and outside of a batch. It depends on what problem you're trying to address.
  • Suggested answer
    Sohaib Cheema Profile Picture
    47,604 User Group Leader on at
    check sysoperation controller class execution context
     
    try this
     
     if (!Global::isRunningOnBatch())
     {
        //non-batch
     }
     else
     {
         //Btach
     }
     

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…

Mansi Soni – Community Spotlight

We are honored to recognize Mansi Soni as our August 2025 Community…

Congratulations to the July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
Sohaib Cheema Profile Picture

Sohaib Cheema 665 User Group Leader

#2
Martin Dráb Profile Picture

Martin Dráb 595 Most Valuable Professional

#3
Yng Lih Profile Picture

Yng Lih 558

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans