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

How to add validation on form data, to date and query value

(1) ShareShare
ReportReport
Posted on by 230
Hi Team,
 
I am creating SSRS report.
 
In dialog i am having From data, To date and query with main account.
 
I have to add validation if Main account is not blank, and from date and to date is exceeds 1 years show the warning if click Ok button in dialog.
 
Please let me know how to show the validation warning.
I have the same question (0)
  • Suggested answer
    Jonas "Jones" Melgaard Profile Picture
    4,988 Most Valuable Professional on at

    Assuming you have written your own controller class for the report, you should implement the 'preRunValidate' method on SrsReportRunController.
    See InventJournalTransTransferController.preRunValidate() for an example of implementation.

    In the method, you can open a dialog to prompt the user, and based on their response, you can modify the return container.


    Edit: Try to do what Martin suggested, it's way prettier. Didn't think that you might have a contract class 😀

  • Suggested answer
    Martin Dráb Profile Picture
    237,990 Most Valuable Professional on at
    From date and To date are dialog fields, most likely coming from a data contract. You can easily add the validation directly to the data contract by implementing SysOperationValidatable interface and validate() method. There you'll compare the values and show a warning and return false if requirements aren't met.
     
    Main account is a query range, therefore you'll need to get the QueryBuildRange object from the query, call its value() method and check if it's empty.
     
    (Moved from Dynamics AX forum.)
  • CU21091228-0 Profile Picture
    230 on at
    Below code i am using in controller class, validate method.
    protected boolean validate()
     {
         boolean        isValid = true;
         ABC_GeneralLedgerReportContract contract;
        
         contract = this.getDataContractObject();
         Query query = this.getFirstQuery();
    
        
         QueryBuildDataSource queryBuildDataSource = query.dataSourceTable(tableNum(MainAccount));
    
         QueryBuildRange queryBuildRange = queryBuildDataSource.findRange(fieldNum(MainAccount, MainAccountId));
         
         if (!queryBuildRange)
         {
             isValid  = warning("");
         }
         
    
         return  isValid;
     }
     
    In case i am not passing any value in MainAccountId, i am not able to get the warning.
  • Suggested answer
    Layan Jwei Profile Picture
    8,124 Super User 2025 Season 2 on at
    Hi,
     
    Since you have a contract class, then you can add the validation there in the validate method. And you also have query in your contract so you can access MainAccount
     
    Check those links:
     
     
    Thanks,
    Layan Jweihan
    Please mark this answer as "Verified" if it solved your issue. In order to help others who will face a similar issue in the future
  • Layan Jwei Profile Picture
    8,124 Super User 2025 Season 2 on at
    Hi,
     
    Is your question answered? If yes, then please verify the answers that helped.

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
Abhilash Warrier Profile Picture

Abhilash Warrier 669 Super User 2025 Season 2

#2
André Arnaud de Calavon Profile Picture

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

#3
Martin Dráb Profile Picture

Martin Dráb 384 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans