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)

Validating SysOperationDataContract using a pop up box for a batch job

(0) ShareShare
ReportReport
Posted on by

Hi all,

I am not sure if it is even possible, but I think I have seen some standard AX batch job doing the same. I have a query on my data contract class that I use in my service class to loop and do stuff in batch.

I want to give users a pop up to say, the query has "10000000" records, you want to continue? 

I tried putting the following in my contract class but the pop up doesnt appear (because it is a batch) and returns it as false. Is there any way to achieve it?

public boolean validate()
{
boolean isValid = false;

QueryRun queryRun = new QueryRun(this.getQuery());
int totalRecords = SysQuery::countTotal(queryRun);

if (totalRecords)
{
if(Box::yesNo(strFmt("This process will work on %1 records, do you want to continue?",totalRecords),DialogButton::No) == DialogButton::Yes)
{
isValid = true;
}
}


return isValid;
}

*This post is locked for comments

I have the same question (0)
  • André Arnaud de Calavon Profile Picture
    301,035 Super User 2025 Season 2 on at

    Hi,

    The batch framework cannot interact with users. Why do you want to display this message? Using a task in the batch assumes that it should be run anyway. If you notice some performance issues, you can review the process and possibly split the work into multiple threads or see if index changes can improve the performance.

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

    You would have to calculate the number of records and show the message already when scheduling the batch, not during its execution. If it's suitable for you, let your data contract class implement SysOperationValidatable interface and put your logic into validate() method. You can find details in documentation: How to: Add Validation to a Data Contract Class.

  • 0993BV Profile Picture
    on at

    Hi Andre,

    I am running the process in multiple threads, but I feel some users can still empty my query and run it for everything (even when it is designed to not be run for that). Just want another failsafe to make sure user knows when they are going to attempt something stupid.

  • 0993BV Profile Picture
    on at

    Hi Martin,

    The validate method example above is only after implementing SysOperationValidatable interface. But of course, it doesnt give a pop up when running as a batch. I will display the message when scheduling (in the main method, before the startoperation method).

    Thanks,

    Vib

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