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

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

Validation on Form

(0) ShareShare
ReportReport
Posted on by

Dear All,

I have added validation on sales order form and validation is working fine. And this validation should happen if user modifies something on the form. We need to allow user modifying sales order, with in  certain range of date. other wise we need to throw an error message saying no changes allowed on sales order. Every thing is fine, but if user doesn't modify any thing on sales order form, if he simply press save button, still validation is happening. And throwing error message  'no changes allowed'.

We know that validateWrite() and Write() methods get call, when we click save button. If we modify something on form and if we click save, then calling of validateWrite() and Write() is ok. If we don't modify anything on form and if we click save, still system calls validateWrite() and Write() methods. 

 Any body know how to check, whether the record is modified or not. It will help me to check this condition, before checking  my validation. 

Thanks,

Akshay

*This post is locked for comments

I have the same question (0)
  • AX 2012 r3 Profile Picture
    2,426 on at

    Hi,

    Hope you are fine.

    Yes Validation methods are called when you save any record.That is for sure.

    But you write some conditions for that whether to validate or not

    You want to know whether the record is modified or not

    you can make a try like this

    CustTable  OldCustTable ,newCustTable;

    oldcusttable = this.orig();         // Record Before change

    this;                                          //Holds new changes

    you can copmare like this

    if(oldcusttable.custid != this.custid)

    {

    //Perform Your Validation

    }

    Regards.

    If you have any doubts.

    let me know.

    Regards.

    Have a great day.

  • Suggested answer
    Vilmos Kintera Profile Picture
    46,149 on at

    Your approach is incorrect. If I would have to implement this only for the SalesTable form, I would override the init() method on the form, and based on your date criteria range, just disable editing of the form datasources, like locking editing every Monday for example:

    if (dayOfWk(systemDateGet()) == 1) // Lock Mondays
    {
        SalesTable_ds.allowEdit(false);
        SalesLine_ds.allowEdit(false);
    }
  • Community Member Profile Picture
    on at

    Thanks for the help.  I tried this.

    Orig() method only works for the fields. If I want to compare whole record it doesn't works.

    I want something like below.

    if(oldcusttable != this)

    {

    }

    but it doesn't works. Is there any other way we have, to manage this.

    Thanks,

  • Vilmos Kintera Profile Picture
    46,149 on at

    Have a look at the solution suggested above, it should meet your requirements to be able to lock editing of the orders within a certain date range criteria (my example for locking it on a specific day).

  • Community Member Profile Picture
    on at

    Hi Vilmos Kintera,

    Even I thought for the same. But my clients specifically wants error message. If nothing works, I will suggest same to clients.

    Regards,

    Akshay

  • Suggested answer
    Vilmos Kintera Profile Picture
    46,149 on at

    You can still add an error to the infolog in canClose method.

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the March Top 10 Community Leaders

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
CP04-islander Profile Picture

CP04-islander 26

#2
imran ul haq Profile Picture

imran ul haq 8

#3
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 4 Super User 2026 Season 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans