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)

how to resist the new command from creating new lines?

(0) ShareShare
ReportReport
Posted on by

i have a form on which i have a method "validateWrite" which throws error on saving each record . As every records gets saved automatically when we click new button on that form and creates a new record.
Buut my form is throwing the error but simultaneously making new record too.
how to resist new record creation while throwing error

regards

rajesh mahato

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Vilmos Kintera Profile Picture
    46,149 on at

    Most likely validateWrite implementation is incorrect. You should not throw an error, but return a false value (or checkFailed in case you want a specific validation failure text message in your infolog).

    Have a look at other tables' validateWrite methods for an example.

  • Community Member Profile Picture
    on at

    Hi Vilmos,

    i have done the same i.e; returned a checkfailed with text message. But the message appears whenever new button is clicked but at the same time a new record gets created.

    kindly let me know

    regards

  • Guruprasanna Profile Picture
    1,089 on at

    If you really want to avoid creation of new lines in the form, you can override the task method of the form and when you click new button, you will get task id as 260, by skipping executing of super() will not create new line.

    write condition like this

    if(_taskId == 260)

       {

       //ret = super(_taskId);

       }

       else

       {

           ret = super(_taskId);

       }

  • Suggested answer
    Nishant2408 Profile Picture
    705 on at

    Hi Rajesh,

    Please check your validateWrite() on the form. Once any validation failure (checkFailed()) occurs execution doesn't stop, it goes further. Please check , is there any other condition written further which is changing your boolean variable's "isValid" value to "True".

    Each time you write a condition use declared boolean inside the "if" statement like -

    public boolean validateWrite()

    {

       boolean isValid;

       isValid = super();

       if (isValid && Your condition)

       {

            //based on your condition

            isValid = checkFailed("------");

       }

       if (isValid && your next condition)

       {

            isValid = checkFailed("-----");

       }

       return isValid;

    }

    Lets say "isValid = super()" returns "false" and further in the code you are checking some condition which is changing the value to "true" then you'll end up getting a validation message and a new line as well. Which was your case

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

    Did you try debugging the insert method past the super call, to see what is the call stack where it is being successfully validated and inserted?

    Why don't you change aosValidateInsert / aosValidateWrite in the table behind then if you want to prevent inserting the record under any circumstances?

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