Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics AX (Archived)

Validating SysOperationDataContract using a pop up box for a batch job

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

  • 0993BV Profile Picture
    0993BV on at
    RE: Validating SysOperationDataContract using a pop up box for a batch job

    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

  • 0993BV Profile Picture
    0993BV on at
    RE: Validating SysOperationDataContract using a pop up box for a batch job

    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.

  • Verified answer
    Martin Dráb Profile Picture
    Martin Dráb 230,214 Most Valuable Professional on at
    RE: Validating SysOperationDataContract using a pop up box for a batch job

    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.

  • André Arnaud de Calavon Profile Picture
    André Arnaud de Cal... 291,280 Super User 2024 Season 2 on at
    RE: Validating SysOperationDataContract using a pop up box for a batch job

    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.

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,214 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans